IE9 JavaScript 错误:SCRIPT5007:无法获取属性“ui”的值:对象为空或未定义
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5787245/
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
IE9 JavaScript error: SCRIPT5007: Unable to get value of the property 'ui': object is null or undefined
提问by Soroush Hakami
My website works well on Chrome, Firefox, and Internet Explorer 8. But on Internet Explorer 9, very weird errors are triggered when just hovering over components.
我的网站在 Chrome、Firefox 和 Internet Explorer 8 上运行良好。但在 Internet Explorer 9 上,将鼠标悬停在组件上时会触发非常奇怪的错误。
SCRIPT5007: Unable to get value of the property 'ui': object is null or undefined ScriptResource.axd?d=sTHNYcjtEdStW2Igkk0K4NaRiBDytPljgMCYpqxV5NEZ1IEtx3DRHufMFtEMwoh2L3771sigGlR2bqlOxaiwXVEvePerLDCL0hFHHUFdTOM0o55K0&t=ffffffffd37cb3a1, line 181 character 1914
SCRIPT5007:无法获得属性 'UI' 的值:对象为空或未定义的ScriptResource.axd d = sTHNYcjtEdStW2Igkk0K4NaRiBDytPljgMCYpqxV5NEZ1IEtx3DRHufMFtEMwoh2L3771sigGlR2bqlOxaiwXVEvePerLDCL0hFHHUFdTOM0o55K0&T = ffffffffd37cb3a1,线181字符1914?
And following the link to the error in the javascript shows me these bits of code:
按照 javascript 中错误的链接向我展示了这些代码:
onNodeOver:function(B,A){A.ui.onOver(B)},onNodeOut:function(B,A){A.ui.onOut(B)}
I'm a little clueless on how to go about solving this error. I've seen thissolution but that didn't solve the problem for me.
我对如何解决这个错误有点无能为力。我已经看到了这个解决方案,但这并没有解决我的问题。
Any Ideas?
有任何想法吗?
回答by Stephen Chung
Many JavaScript libraries (especially non-recent ones) do not handle IE9 well because it breaks with IE8 in the handling of a lot of things.
许多 JavaScript 库(尤其是非最近的库)不能很好地处理 IE9,因为它在处理很多事情时与 IE8 不符。
JS code that sniffs for IE will fail quite frequently in IE9, unless such code is rewritten to handle IE9 specifically.
嗅探 IE 的 JS 代码在 IE9 中会经常失败,除非重写此类代码以专门处理 IE9。
Before the JS code is updated, you should use the "X-UA-Compatible" meta tag to force your web page into IE8 mode.
在 JS 代码更新之前,您应该使用“X-UA-Compatible”元标记来强制您的网页进入 IE8 模式。
EDIT:Can't believe that, 3 years later and we're onto IE11, and there are still up-votes for this. :-) Many JS libraries should now at least support IE9 natively and most support IE10, so it is unlikely that you'll need the meta tag these days, unless you don't intend to upgrade your JS library. But beware that IE10 changes things regarding to cross-domain scripting and some CDN-based library code breaks. Check your library version. For example, Dojo 1.9 on the CDN will break on IE10, but 1.9.1 solves it.
编辑:不敢相信,3 年后,我们进入了 IE11,而且仍然有赞成票。:-) 许多 JS 库现在至少应该原生支持 IE9,并且大多数都支持 IE10,所以现在你不太可能需要元标记,除非你不打算升级你的 JS 库。但请注意,IE10 会更改有关跨域脚本和某些基于 CDN 的库代码中断的内容。检查您的库版本。比如CDN上的Dojo 1.9在IE10上会破解,但是1.9.1解决了。
EDIT 2:You REALLYneed to get your acts together now. We are now in mid-2014!!! I am STILLgetting up-votes for this! Revise your sites to get rid of old-IE hard-coded dependencies!
编辑 2:你现在真的需要把你的行为放在一起。我们现在是 2014 年年中!!!我仍然为此投票!修改您的网站以摆脱旧的 IE 硬编码依赖项!
Sigh... If I had known that this would be by far my most popular answer, I'd probably have spent more time polishing it...
叹息...如果我知道这将是迄今为止我最受欢迎的答案,我可能会花更多的时间来完善它...
EDIT 3:It is now almost 2016. Upvotes still ticking up... I guess there are lotsof legacy code out there... One day our programs will out-live us...
编辑 3:现在快到 2016 年了。投票仍在增加……我想那里有很多遗留代码……总有一天我们的程序会比我们活得更久……
回答by savan
I was having same issue in IE9. I followed the above answer and I added the line:
我在 IE9 中遇到了同样的问题。我遵循了上面的答案,并添加了以下行:
<meta http-equiv="X-UA-Compatible" content="IE=8;FF=3;OtherUA=4" />
in my <head>
and it worked.
在我的<head>
和它的工作。
回答by Justin Russo
I have written code that sniffs IE4 or greater and is currently functioning perfectly in sites for my company's clients, as well as my own personal sites.
我编写了嗅探 IE4 或更高版本的代码,目前在我公司客户的站点以及我自己的个人站点中运行良好。
Include the following enumerated constant and function variables into a javascript include file on your page...
将以下枚举常量和函数变量包含到页面上的 javascript 包含文件中...
//methods
var BrowserTypes = {
Unknown: 0,
FireFox: 1,
Chrome: 2,
Safari: 3,
IE: 4,
IE7: 5,
IE8: 6,
IE9: 7,
IE10: 8,
IE11: 8,
IE12: 8
};
var Browser = function () {
try {
//declares
var type;
var version;
var sVersion;
//process
switch (navigator.appName.toLowerCase()) {
case "microsoft internet explorer":
type = BrowserTypes.IE;
sVersion = navigator.appVersion.substring(navigator.appVersion.indexOf('MSIE') + 5, navigator.appVersion.length);
version = parseFloat(sVersion.split(";")[0]);
switch (parseInt(version)) {
case 7:
type = BrowserTypes.IE7;
break;
case 8:
type = BrowserTypes.IE8;
break;
case 9:
type = BrowserTypes.IE9;
break;
case 10:
type = BrowserTypes.IE10;
break;
case 11:
type = BrowserTypes.IE11;
break;
case 12:
type = BrowserTypes.IE12;
break;
}
break;
case "netscape":
if (navigator.userAgent.toLowerCase().indexOf("chrome") > -1) { type = BrowserTypes.Chrome; }
else { if (navigator.userAgent.toLowerCase().indexOf("firefox") > -1) { type = BrowserTypes.FireFox } };
break;
default:
type = BrowserTypes.Unknown;
break;
}
//returns
return type;
} catch (ex) {
}
};
Then all you have to do is use any conditional functionality such as...
然后您所要做的就是使用任何条件功能,例如...
ie. value = (Browser() >= BrowserTypes.IE) ? node.text : node.textContent;
IE。 value = (Browser() >= BrowserTypes.IE) ? node.text : node.textContent;
or WindowWidth = (((Browser() >= BrowserTypes.IE9) || (Browser() < BrowserTypes.IE)) ? window.innerWidth : document.documentElement.clientWidth);
或者 WindowWidth = (((Browser() >= BrowserTypes.IE9) || (Browser() < BrowserTypes.IE)) ? window.innerWidth : document.documentElement.clientWidth);
or sJSON = (Browser() >= BrowserTypes.IE) ? xmlElement.text : xmlElement.textContent;
或者 sJSON = (Browser() >= BrowserTypes.IE) ? xmlElement.text : xmlElement.textContent;
Get the idea? Hope this helps.
明白了吗?希望这可以帮助。
Oh, you might want to keep it in mind to QA the Browser() function after IE10 is released, just to verify they didn't change the rules.
哦,你可能要记住在IE10发布后对Browser()函数进行QA,只是为了验证他们没有改变规则。
回答by fender
This worked for me in IE 11:
这在 IE 11 中对我有用:
<meta http-equiv="x-ua-compatible" content="IE=edge; charset=UTF-8">
回答by des1roer
check whether there is a comma at the end.
检查末尾是否有逗号。
},
{
name: 'МОФ. Перелив из баков. м3/ч',
data: graph_high3,
dataGrouping: {
units: groupingUnits,
groupPixelWidth: 40,
approximation: "average",
enabled: true,
units: [[
'minute',
[1]
]]
}
} // if , - SCRIPT5007
回答by Rosdi Kasim
You could also get this error if you are viewing accessing the page locally (via file://
instead of http://
)..
如果您正在查看本地访问页面(通过file://
而不是http://
),您也可能会收到此错误。
There is some discussion about this here: https://github.com/jeromegn/Backbone.localStorage/issues/55
这里有一些讨论:https: //github.com/jeromegn/Backbone.localStorage/issues/55
回答by Fazi
Well, you should also try adding the Javascript code into a function, then calling the function after document body has loaded..it worked for me :)
好吧,您还应该尝试将 Javascript 代码添加到函数中,然后在文档正文加载后调用该函数..它对我有用:)
回答by Mazhar Khan
I was also facing the same issue.
我也面临同样的问题。
I was using the code below in .aspx page without writing authentication configuration in web.config file. After writing the settings in Web.config, I am able to run my code.
我在 .aspx 页面中使用了下面的代码,而没有在 web.config 文件中编写身份验证配置。在 Web.config 中写入设置后,我就可以运行我的代码了。
<% If Request.IsAuthenticated Then%>
<table></table>
<%end if%>