使用 Visual Studio 2013,我将混合 Asp.Net Webforms/MVC 3 Web 应用程序迁移到 Asp.Net Webforms/MVC 5.1。作为迁移的一部分,我使用 NuGet 包管理器将 Jquery 从 1.9.1 升级到 2.1.1。
当我在 Chrome 中的 Visual Studio 2013 调试器中运行应用程序时,我没有问题。
当我在 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>
它失败并出现此 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'
我意识到 Jquery 2 不适用于 IE 8 及更低版本,但我找不到任何说明 IE 9 存在任何问题的文档。
错误发生在 jQuery.ready.promise 函数内 jquery-2.1.1.js 的第 3425 行:
document.addEventListener( "DOMContentLoaded", completed, false );
奇怪的是,当我停在错误处时,检查调试器中的文档对象并展开“方法”节点,我可以看到“addEventListener”方法。就好像 Jquery 无权查看该方法一样。
我非常想升级到 Jquery 2,从我读过的所有内容来看,Jquery 2 应该可以与 IE9 一起使用。有关解决此问题的任何建议?