IE8不支持querySelectorAll [英] IE8 does not support querySelectorAll

查看:616
本文介绍了IE8不支持querySelectorAll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用 document.querySelectorAll(),但IE8抛出错误,

I tried to use document.querySelectorAll(), but IE8 throw error, that


对象不支持此属性或方法

Object doesn't support this property or method



var titleCheckBox = document.querySelectorAll("");

这里 http://www.quirksmode.org/dom/w3c_core.html#t13 ,即IE8支持这种方法。
我做错了什么?

Here http://www.quirksmode.org/dom/w3c_core.html#t13 written, that IE8 support this method. What I doing wrong?

推荐答案

检查您的页面是否处于Quirks模式或兼容模式。您可以使用F12开发工具进行确认。按F12并查看生成窗口的右上角。如果您在模式说明中看到兼容性或怪癖,那么您就发现了问题。

Check that your page isn't in Quirks mode or Compatibility mode. You can use the F12 dev tools to confirm this. Press F12 and look in the top-right corner of the resulting window. If you see "Compatibility" or "Quirks" in the mode description, then you've found the problem.


  • Quirks模式:这通常是由缺少或损坏的Doctype触发的。如果是这种情况,请确保您的网页以以下内容开头:

  • Quirks mode: this is usually triggered by a missing or broken Doctype. If this is the case, make sure your page starts with the following:

<!DOCTYPE html>


  • 兼容模式(IE7模式):这可能会被触发如果您在本地查看页面(即在本地计算机上运行,​​例如进行测试,或在本地网络上运行)。在这种情况下,您将被要禁用的IE配置设置命中。转到工具菜单,然后选择Comaptibility视图设置选项。取消兼容性选项,页面应该开始工作。

  • Compatibility mode (IE7 mode): This may be triggered if you're viewing the page locally (ie running it on your local machine, eg for testing, or on your local network). In this case, you are being hit by an IE config setting that you should disable. Go to the Tools menu, and pick the Comaptibility View Settings option. Untick the compatibility options, and the page should start working.

    也可以通过 X-UA兼容性触发(或避免)Compat模式元标记。如果您在兼容模式下遇到问题,这是避免它的好方法:在代码中添加以下行:

    Compat mode may also be triggered (or avoided) by an X-UA-Compatibility meta tag. If you're having trouble with compatibility mode, this is a good way to avoid it: Add the following line to your code:

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


  • 上述任何一项(或两项)均可是问题,但我的猜测是问题是兼容模式。内部网站上的compat-mode-onnet网站设置令人惊讶地鲜为人知,并且吸引了很多人,甚至是一些经验丰富的开发人员。

    Either (or both) of the above could be the problem, but my guess is that the problem is compatibility mode. The compat-mode-on-intranet-sites setting is suprisingly little known, and catches a lot of people out, even some seasoned developers.

    这篇关于IE8不支持querySelectorAll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆