【问题标题】:JavaScript runtime error: Unable to get property 'msie' of undefined or null referenceJavaScript 运行时错误:无法获取未定义或空引用的属性“msie”
【发布时间】:2013-10-06 15:54:01
【问题描述】:

我刚刚尝试将我的 jquery ui 引用更改为母版页。我只在 Internet Explorer 上收到上述错误。 我在 Firefox 和 Chrome 上没有收到错误消息。

这是抛出错误的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 库没有被加载。

【问题讨论】:

    标签: c# javascript jquery asp.net jquery-ui


    【解决方案1】:

    jQuery.browser 在 jQuery 1.9 中一直是 removed(并且您使用 1.10),因此任何将其作为对象处理(即访问其 msie 属性)的尝试都注定会失败。如果您仍然想使用它,请在 jQuery 中包含 jQuery migrate 插件

    【讨论】:

    • 嘿raina770w 谢谢!我想将 jquery.browser 代码更改为其更新版本。你能告诉我我应该做什么吗?这样我的代码就可以在不添加新参考的情况下工作。谢谢!
    • @Courage 根据raina77ow 的答案中链接的jQuery API 页面,使用jQuery 迁移插件似乎是唯一的方法。它说,“这个属性在 jQuery 1.9 中被删除,只能通过 jQuery.migrate 插件使用。请尝试使用特征检测。”
    • 我仍然收到文档中加载的 jquery migrate 的错误
    【解决方案2】:

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

    【讨论】:

      【解决方案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>
      

      【讨论】:

      • 或者只是 // 如果您希望协议与您的网站相匹配
      【解决方案4】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-07-10
        • 2013-09-30
        • 1970-01-01
        • 1970-01-01
        • 2015-07-07
        • 2014-02-22
        • 2017-07-17
        • 2015-02-27
        相关资源
        最近更新 更多