IE9 上的 jQuery 问题...
使用 IE9 F12 开发人员工具,我在控制台中看到这些错误:
SCRIPT438: Object doesn't support property or method 'getElementsByTagName'
jquery.min.js, line 16 character 59007
SCRIPT438: Object doesn't support property or method 'getElementsByTagName'
jquery.min.js, line 16 character 59007
这些错误可能与我的问题无关(即使有问题的代码被注释掉,这个错误无论如何都会出现一次......)。
jQuery 肯定会停止执行,因为网站上的 jQuery 都不能在 IE9 中运行。它在 FF、Chrome、Safari 和 Iphone(也包括 safari)上运行没有任何问题。
我已经将破坏代码的范围缩小到了下面(我知道,因为当它消失时一切正常):
<script type="text/javascript">
$(document).ready(function() {
var $alertdiv = $('<div id = "alertmsg"/>');
/*$alertdiv.text("");*/
$alertdiv.bind('click', function() {
$(this).slideUp(200);
});
$(document.body).append($alertdiv);
$("#alertmsg").slideDown("slow");
setTimeout(function() { $alertdiv.slideUp(200) }, 10000);
});
</script>
该脚本在其他浏览器上运行时,会滑下带有消息的 Twitter 样式通知栏,如定义的在alertmsg div 中。
有没有人看到什么可能只在 IE9 中导致这个问题?
Using IE9 F12 developer tools, I see these errors in the console:
SCRIPT438: Object doesn't support property or method 'getElementsByTagName'
jquery.min.js, line 16 character 59007
SCRIPT438: Object doesn't support property or method 'getElementsByTagName'
jquery.min.js, line 16 character 59007
These errors may have nothing to do with my issue (even when the troubled code is commented out, this error appears once anyway...).
The jQuery stops executing, definitely, because none of the jQuery on the site works in IE9. It works without any issue in FF, Chrome, Safari, and on the Iphone (safari as well).
I have narrowed down the code that is breaking things to this below (I know, because everything works fine when this is gone):
<script type="text/javascript">
$(document).ready(function() {
var $alertdiv = $('<div id = "alertmsg"/>');
/*$alertdiv.text("");*/
$alertdiv.bind('click', function() {
$(this).slideUp(200);
});
$(document.body).append($alertdiv);
$("#alertmsg").slideDown("slow");
setTimeout(function() { $alertdiv.slideUp(200) }, 10000);
});
</script>
This script, when functioning on other browsers, slides down a twitter-style notification bar with a message, as defined in the alertmsg div.
Does anyone see anything that could be causing this problem in IE9 only?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,这是旧版本 jQuery 库中的一个错误( jQuery 模板无法在IE9 RC )...
我引用了最新的 jQuery (v1.6.4) - 我立即启动并运行...
感谢大家的帮助!
Ok, it was a bug in older versions of jQuery library ( jQuery Templates not working in IE9 RC )...
I referenced the latest jQuery (v1.6.4) - and I was instantly up and running...
Thanks all for the help!