SCRIPT1014:字符无效

我有这个脚本:

function slideSwitch() { var ae = jQuery('#featured-right a.active'); if ( ae.length == 0 ) { ae = jQuery('#featured-right a:first'); var i = jQuery('#featured-right a').index(ae); var bae = jQuery('#featured-left a.fb-'+i); bae.show(); } var ne = ae.next().length ? ae.next() : jQuery('#featured-right a:first'); } $(document).ready(function(){ var ae = jQuery('#featured-right a.active'); if ( ae.length == 0 ) { ae = jQuery('#featured-right a:first'); ae.addClass('active'); var i = jQuery('#featured-right a').index(ae); jQuery('#featured-left a.fb-'+i).show(); jQuery('#featured-right a:not(.active) span.key').hide(); } setInterval("slideSwitch()", 1000); }); 

这适用于任何浏览器,但IE。 在IE上,IU得到

 SCRIPT1014: Invalid character featured.js, line 1 character 1 

这有什么不对?

IE似乎不喜欢我没有HTTP服务器访问页面的事实:)我正在访问c:\ www \ my-file。 访问http:// localhost / my-file ..工作得很好。

我有同样的问题。 它说主文件的第1行第1行出错了。 我在我使用的页面中使用了大量的AJAX。

这一切都归结为我在A标签上有onclick =“#”这一事实。 删除后,错误就消失了。

我认为当jQuery通过AJAX调用加载html时,它需要onclick标签并处理它在里面找到的javascript。

问题可能是该文件是UTF-8编码的,并且该文件是通过脚本标记引入的,该脚本标记未定义此编码。 如果您将charset="UTF-8"作为属性添加到导入脚本标记,希望能够解决它。

注意模板字符串文字。 此错误是由a引起的

 ` 

在IE11中我的角色。