IE 10: 对象不支持 selectNodes 属性或方法

IE 10: 提示 “对象不支持 selectNodes 属性或方法

用Ajax请求返回的xml ,一般浏览器都能用 responseXML.documentElement.selectNodes("XXX") 去检索需要的节点,但是IE升级到10之后对象不支持selectNodes()属性或者方法!

selectNodes()方法是依赖于 msxml 的,在IE8,9的时候,浏览器处理了返回的XML格式的doucment , 使之变为 msxml-document ,正常使用 selectNode() 方法没有问题。但是IE10去掉了这一处理,返回原生的 XML , 需要手动设置成 msxml。

解決方法:
  
    发送Ajax请求之前,加一句:
    xmlHttp.open(....);
    try{
     xmlHttp.responseType("msxml-document");
    }catch(e){
    }
    xmlHttp.send(null);


或者让IE10选择IE9兼容模式:

In PHP, if you want to only put the tag in if it's IE10, you can do this:

$isIE10 = (bool) preg_match('/(?i)msie [10]/',$_SERVER['HTTP_USER_AGENT']);
if ($isIE10) echo '<meta http-equiv="X-UA-Compatible" content="IE=9" />';


你可能感兴趣的:(IE 10: 对象不支持 selectNodes 属性或方法)