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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19100085/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 14:05:16  来源:igfitidea点击:

JavaScript runtime error: Unable to get property 'msie' of undefined or null reference

c#javascriptjqueryasp.netjquery-ui

提问by CodeNinja

I just tried changing my jquery ui references to the master page . I get the error above only on Internet explorer. I dont get the error on Firefox and Chrome .

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

This is the jquery code where the error is thrown :

这是引发错误的 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()

I have the master page below :

我有下面的母版页:

<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>

Please let me know what I need to be doing ? I tried putting the jquery references in the head section , but the jquery code within my aspx file seems to give an error saying 'dialog' object not defined or 'tooltip' object not defined. I think the jquery library is not getting loaded when I try to put the references in the head section.

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

采纳答案by raina77ow

jQuery.browserhas been removedin jQuery 1.9 (and you use 1.10), so any attempt to process it as an object (i.e., access its msieproperty) is destined to fail. If you still want to use it, include jQuery migrateplugin along with jQuery

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

回答by Shahbaz Ahmad

Add library from given link in your project.

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

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

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

or

或者

Register below link in your page

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

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

回答by Roger Perkins

I updated jquery-ui to 1.11.3 and the problem went away.

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

回答by Matthew Lock

The jquery-browser-pluginnow provides the $.browser object. Including $.browser.msie

jQuery的浏览器插件现在提供$ .browser对象。包括 $.browser.msie