我正在加载 jQuery,它导致 Opera(以及单独的 Opera)中出现 CSS 错误。我创建了一个JSFiddle来演示。
使用一些 CSS 来设置 HTML 和 BODY 标记的样式,例如:
html {
background: #6B9AB6;
}
body {
background: white;
max-width: 10em;
}
然后加载 jQuery(使用简单的 setTimeout
进行演示):
setTimeout(function(){
var script_tag = document.createElement('script');
script_tag.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js';
var script_sib = document.getElementsByTagName('script')[0];
script_sib.parentNode.insertBefore(script_tag, script_sib);
}, 2000);
导致显示正确的 CSS,然后闪现到无样式的 HTML 标记。使用 Opera 的 DragonFly 并更改 background-attachment
或 background-origin
可以动态修复此问题。如果您以编程方式执行此操作,则情况并非如此。
有没有办法让 Opera 与后加载的 jQuery 一起工作?如果您有任何想法,请随时更新 JSFiddle。
最佳答案
这是 jQuery 1.6 版本中的回归; jQuery version 1.5.2 works just fine .
目前有is a patch通过阿德蒂:
The bug can be resolved on ligne [line number] 1288 from jquery-1.6.1.js.
Replace :
"documentElement.insertBefore( body, documentElement.firstChild );"
by
"documentElement.appendChild( body );"
如果您自行托管该库,这会产生奇迹。
编辑:版本 1.6.2 已修复此问题(当前位于 jQuery's GIT 存储库中)。
关于jquery - 使用 Opera 加载 jQuery 后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6428868/