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

匿名 (未验证) 提交于 2019-12-03 08:46:08

问题:

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 .

This is the jquery code where the error is thrown :

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.

回答1:

jQuery.browser has been removed in jQuery 1.9 (and you use 1.10), so any attempt to process it as an object (i.e., access its msie property) is destined to fail. If you still want to use it, include jQuery migrate plugin along with jQuery



回答2:

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



回答3:

Add library from given link in your project.

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> 


回答4:

The jquery-browser-plugin now provides the $.browser object. Including $.browser.msie



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!