javascript IE9 JS 无法获取属性“显示”的值:对象为空或未定义

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10945835/
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-10-26 11:34:50  来源:igfitidea点击:

IE9 JS Unable to get value of the property 'display': object is null or undefined

javascriptmagentoprototypejsinternet-explorer-9

提问by zigoHymano

Recently launched a Magento store which features an image slider on the homepage. Works perfectly in Firefox, Chrome etc etc but as usual, IE9 is causing issues - the strange thing is, this was working in IE so not sure what has caused it to stop functioning.

最近推出了一个 Magento 商店,在主页上有一个图像滑块。在 Firefox、Chrome 等中完美运行,但像往常一样,IE9 导致问题 - 奇怪的是,这是在 IE 中运行的,所以不确定是什么导致它停止运行。

As it stands, in IE9, it cannot detect the range of images in the slider (only displays the first in the sequence) and subsequently doesn't slide anywhere.

就目前而言,在 IE9 中,它无法检测滑块中的图像范围(仅显示序列中的第一个)并且随后不会在任何地方滑动。

In IE9 developer mode, errors are:-

在 IE9 开发者模式下,错误是:-

=======#

========#

SCRIPT438: Object doesn't support property or method 'dispatchEvent'
prototype.js, line 5734 character 7

Code snippet:

代码片段:

5733 if (document.createEvent)
5734   element.dispatchEvent(event);
5735 else
5736   element.fireEvent(event.eventType, event);

=======#

========#

And...

和...

=======#

========#

SCRIPT5007: Unable to get value of the property 'display': object is null or undefined
prototype.js, line 2542 character 5

Code snippet:

代码片段:

2538 else if (Prototype.Browser.IE) {
2539   Element.Methods.getStyle = function(element, style) {
2540     element = $(element);
2541     style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize();
2542     var value = element.style[style];
2543     if (!value && element.currentStyle) value = element.currentStyle[style];

=======#

========#

In Magento (1.6.2.0), we're using latest version of prototype.js (1.7).

在 Magento (1.6.2.0) 中,我们使用最新版本的prototype.js (1.7)。

We've also added IE standards mode to the head...

我们还在头部添加了 IE 标准模式...

<!-- Enable IE8 Standards mode -->
<meta http-equiv="X-UA-Compatible" content="IE=8" >

Similar errors do appear in Firefox and Chrome but they don't appear to affect the functionality.

类似的错误确实出现在 Firefox 和 Chrome 中,但它们似乎不会影响功能。

Please could anyone be as kind to take a look and advise of where the problem could be as I'm unsure what to fix. Site in question is http://www.showermania.co.uk/

请任何人都可以像我不确定要解决的问题一样,看看问题出在哪里并提出建议。有问题的网站是http://www.showermania.co.uk/

Thanks in advance.

提前致谢。

回答by zigoHymano

Resolved the issue in the end.

最终解决了这个问题。

Reset Magento's session cookie management settings (it's probably also worth clearing cache, reindexing all and clearing any sessions and locks whilst your at it). It solved my issue (weirdly) so if anyone experiences something similar, it's probably worth a shot.

重置 Magento 的会话 cookie 管理设置(可能还值得清除缓存、重新索引所有内容并在您使用它时清除所有会话和锁定)。它解决了我的问题(奇怪地)所以如果有人遇到类似的事情,它可能值得一试。

回答by Jules

I had the same error in one of my apps. To fix it I changed the X-UA-COMPATIBLE to:

我在我的一个应用程序中遇到了同样的错误。为了修复它,我将 X-UA-COMPATIBLE 更改为:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9">