javascript bgiframe 插件导致 IE9 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6424526/
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
bgiframe plugin causes error in IE9
提问by Tillito
The uiquery plugin bgiframe (version 2.1.1) causes the following java script error in Internet Explorer 9:
uiquery 插件 bgiframe(版本 2.1.1)在 Internet Explorer 9 中导致以下 java 脚本错误:
jquery.bgiframe.js, line 94 character 5
My menu does not work any more, I hope the reason is this error.
我的菜单不再工作了,我希望是这个错误的原因。
Any ideas?
有任何想法吗?
ADDED:
添加:
The line in jquery.bgiframe.js is:
jquery.bgiframe.js 中的行是:
this.insertBefore( document.createElement(html), this.firstChild );
and the error sais:
和错误说:
SCRIPT5022: DOM Exception: INVALID_CHARACTER_ERR (5)
采纳答案by Tillito
After some more research I found a solution myself on the bgiframe site:
经过更多研究,我自己在 bgiframe 站点上找到了一个解决方案:
I downloaded version 2.1.3-pre at
我下载了 2.1.3-pre 版本
https://github.com/brandonaaron/bgiframe/blob/master/jquery.bgiframe.js
https://github.com/brandonaaron/bgiframe/blob/master/jquery.bgiframe.js
and this solved the problem.
这解决了问题。
回答by Robert
In the plugin code for bgiframe version 2.1.1 was doing a regex search for "6.0" but it needs to search for "MSIE 6.0". Tillito has found the correct source.
在 bgiframe 版本 2.1.1 的插件代码中,正在对“6.0”进行正则表达式搜索,但它需要搜索“MSIE 6.0”。Tillito 找到了正确的来源。
In the bgiframe code look for:
在 bgiframe 代码中查找:
if($.browser.msie&&/6.0/.test(navigator.userAgent)
if($.browser.msie&&/6.0/.test(navigator.userAgent)
Change to:
改成:
if($.browser.msie && /msie 6\.0/i.test(navigator.userAgent)
if($.browser.msie && /msie 6\.0/i.test(navigator.userAgent)
OR just get the source here: https://github.com/brandonaaron/bgiframe/blob/master/jquery.bgiframe.js
或者只是在这里获取源代码:https: //github.com/brandonaaron/bgiframe/blob/master/jquery.bgiframe.js
回答by saku19791128
var parent = document.createElement("div");
parent.innerHTML = html;
this.insertBefore( parent, this.firstChild );
回答by Joe
Add below tag after head tag
在 head 标签后添加下面的标签
<meta http-equiv="X-UA-Compatible" content="IE=8" />