【问题标题】:Issues with jQuery on IE9...IE9上的jQuery问题...
【发布时间】:2011-09-26 23:54:02
【问题描述】:

使用 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 中导致此问题的内容?

【问题讨论】:

  • 你能隔离导致它的行吗?这里有几个选项。预感——尝试将 '
    ' 更改为 '
    '
  • 有没有机会链接到该网站?
  • 在所有版本的 IE(包括 IE9)中,在 jsFiddle 中对我来说似乎都可以正常工作:jsfiddle.net/jfriend00/P6TFK。我建议您将此行更改为完整的 HTML:var $alertdiv = $('&lt;div id="alertmsg"&gt;&lt;/div&gt;');
  • @karnyj - 不走运。和你一样 jfriend00。也很疯狂的是,这在 IE8 和 IE7 上也能正常工作......三十点,抱歉我无法链接到该网站 - 不幸的是包含私人信息。
  • 我也尝试注释掉上面的其他行...从来没有运气...

标签: jquery internet-explorer-9 notification-bar


【解决方案1】:

好的,这是旧版本 jQuery 库 (jQuery Templates not working in IE9 RC) 中的一个错误...

我引用了最新的 jQuery (v1.6.4) - 我立即启动并运行...

感谢大家的帮助!

【讨论】:

  • 注意:我认为这是 1.5 版中的错误,并在 1.5.1 中修复,因此您无需一直更新到 1.6.4 即可修复。 Source
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-10-01
  • 1970-01-01
  • 2012-05-24
  • 1970-01-01
相关资源
最近更新 更多