简体   繁体   English

IE9中的Jquery 2.1.1得到错误:0x800a01b6-Microsoft JScript运行时错误:对象不支持属性或方法'addEventListener'

[英]Jquery 2.1.1 in IE9 get error: 0x800a01b6 - Microsoft JScript runtime error: Object doesn't support property or method 'addEventListener'

Using Visual Studio 2013, I migrated a hybrid Asp.Net Webforms/MVC 3 web application to Asp.Net Webforms/MVC 5.1. 使用Visual Studio 2013,我将混合的Asp.Net Webforms / MVC 3 Web应用程序迁移到Asp.Net Webforms / MVC 5.1。 As part of the migration I upgraded Jquery from 1.9.1 to 2.1.1, using the NuGet package manager. 作为迁移的一部分,我使用NuGet包管理器将Jquery从1.9.1升级到2.1.1。

When I run the application in the Visual Studio 2013 debugger in Chrome I have no problem. 当我在Chrome的Visual Studio 2013调试器中运行应用程序时,我没有问题。

When I run the application in the Visual Studio 2013 debugger in IE 9 (compatibilty mode is not on) a master page with these two script tags loads first: 当我在IE 9中的Visual Studio 2013调试器中运行应用程序时(不启用兼容模式),首先加载具有以下两个脚本标记的母版页:

<script src="/Scripts/jquery-2.1.1.js" type="text/javascript"></script>
<script src="/Scripts/jquery-ui-1.10.4.js" type="text/javascript"></script>

It fails with this Javascript error: 它因以下Javascript错误而失败:

Unhandled exception at line 3425, column 4 in http://localhost:25378/Scripts/jquery-2.1.1.js 
0x800a01b6 - Microsoft JScript runtime error: Object doesn't support property or method 'addEventListener'

I realize that Jquery 2 does not work with IE 8 and below, but I cannot find any documentation noting any issues with IE 9. 我意识到Jquery 2不适用于IE 8及更低版本,但是我找不到任何文档来说明IE 9的任何问题。

The error occurs on line 3425 of jquery-2.1.1.js inside the jQuery.ready.promise function: 该错误发生在jQuery.ready.promise函数内的jquery-2.1.1.js的第3425行上:

document.addEventListener( "DOMContentLoaded", completed, false );

Strangely, when I stop at the error, examine the document object in the debugger and expand the "Methods" node I can see the "addEventListener" method. 奇怪的是,当我停止错误时,请在调试器中检查文档对象,然后展开“方法”节点,可以看到“ addEventListener”方法。 It is as if Jquery does not have rights to see the method. 好像Jquery没有权限查看该方法。

I'd very much like to move up to Jquery 2, and from everything I've read Jquery 2 should work with IE9. 我非常想升级到Jquery 2,从我读过的所有文章来看,Jquery 2都应与IE9兼容。 Any advice on fixing this issue? 关于解决此问题有什么建议吗?

Thank you ᾠῗᵲᄐᶌ and QBM5 for your comments, the answer in this case was to remove 谢谢ᾠῗᵲᄐᶌ和QBM5的评论,在这种情况下,答案是删除

<meta http-equiv="X-UA-Compatible" content="IE=8">

from the master page header, because it put the browser into IE 8 compatibility mode, and IE 8 is not compatible with JQuery 2. 因为它使浏览器进入IE 8兼容模式,并且IE 8与JQuery 2不兼容,所以它来自母版页标题。

I was getting the same error with a brand new web app in VS2013 Ultimate. 我在VS2013 Ultimate中使用全新的Web应用程序时遇到了相同的错误。 Turns out IE11 was running in compatibility mode - turning that off got rid of the error 原来IE11在兼容模式下运行-关闭该功能可以消除错误

I was getting similar exception while using JQuery in IE8. 在IE8中使用JQuery时遇到类似的异常。 and found solution 找到解决方法

<head id="Head1" runat="server"> 
    <!--[if lt IE 9]>
        <script src="/js/trirand/jquery-1.11.1.min.js" type="text/javascript"></script> 
    <![endif]-->

    <!--[if gt IE 8]>
        <script src="/js/trirand/jquery-2.1.1.min.js" type="text/javascript"></script> 
        <![endif]-->
</head>

you can change version if need. 您可以根据需要更改版本。

From the code: IE8 and lesser versions support jQuery1X versions 来自代码: IE8和更低版本支持jQuery1X版本

Jquery2x versions are working in IE9 and higher versions. Jquery2x版本可在IE9及更高版本中使用。

Good luck 祝好运

You can add below code in your web config file for setting document mode: 您可以在Web配置文件中添加以下代码以设置文档模式:

<system.webServer>
  <httpProtocol>
    <customHeaders>
     <add name="X-UA-Compatible" value="IE=EmulateIE9" />
    </customHeaders>
 </httpProtocol>
</system.webServer>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ul上的JQuery菜单方法抛出“ 0x800a01b6-Microsoft JScript运行时错误:对象不支持此属性或方法” - JQuery menu method on ul throws “0x800a01b6 - Microsoft JScript runtime error: Object doesn't support this property or method” 0x800a01b6-JavaScript运行时错误:对象不支持属性或方法“ appendTo” - 0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'appendTo' 0x800a01b6-JavaScript运行时错误:对象不支持属性或方法“ cookie” - 0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'cookie' 0x800a01b6 - JavaScript运行时错误:对象不支持属性或方法'tabs' - 0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'tabs' 0x800a01b6-JavaScript运行时错误:对象不支持属性或方法“时间选择器” - 0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'timepicker' 0x800a01b6-JavaScript运行时错误:对象不支持属性或方法&#39;SumoSelect&#39; - 0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'SumoSelect' 0x800a01b6-JavaScript运行时错误:对象不支持属性或方法“ getElementsByTagName” - 0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'getElementsByTagName' 0x800a01b6-JavaScript运行时错误:对象不支持属性或方法“调用” - 0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'call' MVC4和datepicker:“0x800a01b6 - JavaScript运行时错误:对象不支持属性或方法&#39;datepicker&#39;” - MVC4 and datepicker: “0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'datepicker'” 错误 0x800a01b6 - 对象不支持属性或方法“attachEvent” - Error 0x800a01b6 - Object doesn't support property or method 'attachEvent'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM