JavaScript 运行时错误:无法获取未定义或空引用的属性“msie”

本文关键字:引用 属性 msie 运行时错误 未定义 获取 JavaScript | 更新日期: 2023-09-27 18:33:24

我刚刚尝试将我的jquery ui引用更改为母版页。我只在IE浏览器上收到上面的错误。我在火狐和铬上没有收到错误。

这是抛出错误的jquery代码:

return a.browser.msie?(b=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth),c=Math.max(document.documentElement.offsetWidth,document.body.offsetWidth),b<c?a(window).width()+"px":b+"px"):a(document).width()+"px"},resize:function(){var b=a([]);a.each(a.ui.dialog.overlay.instances,function()

我在下面有母版页:

<head id="Head1" runat="server">
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/redmond/jquery-ui.css"
        type="text/css" />
    <asp:ContentPlaceHolder ID="ExtraHeadContent" runat="server">
    </asp:ContentPlaceHolder>
</head>

 <form id="form2" runat="server">
    <asp:ScriptManager ID="ScriptManagerService" runat="server">
        <Scripts>
            <asp:ScriptReference Path="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" ScriptMode="Auto" />
            <asp:ScriptReference Path="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js" ScriptMode="Auto" />
        </Scripts>
    </asp:ScriptManager>
</form>
</body>

请让我知道我需要做什么?我尝试将 jquery 引用放在 head 部分,但我的 aspx 文件中的 jquery 代码似乎给出了一个错误,指出未定义"对话框"对象或未定义"工具提示"对象。我认为当我尝试将引用放在 head 部分中时,jquery 库没有加载。

JavaScript 运行时错误:无法获取未定义或空引用的属性“msie”

jQuery.browser在jQuery 1.9中已被删除(并且您使用1.10),因此任何将其作为对象处理(即访问其msie属性)的尝试都注定要失败。如果您仍然想使用它,请包含jQuery migrate plugin以及jQuery

我将jquery-ui更新到1.11.3,问题消失了。

从项目中的给定链接添加库。

http://code.jquery.com/jquery-migrate-1.2.1.js

在您的页面中注册以下链接

<script type="text/javascript" src="code.jquery.com/jquery-migrate-1.2.1.js"></script>

jquery-browser-plugin 现在提供了 $.browser 对象。包括 $.browser.msie