javascript Xpathresult 在 IE11 中未定义

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23560438/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 01:05:54  来源:igfitidea点击:

Xpathresult is undefined in IE11

javascriptinternet-explorer-11

提问by Sadia H

I am using some javascripts. I used

我正在使用一些 javascripts。我用了

var xpathResults = document.evaluate(xpath, domContext, null, XPathResult.ANY_TYPE, null);

it is working fine in all the browser except IE11. It is showing error: 'XPathResult is undefined'. And yes I used wgxpath.install.jsscript before that.

它在除 IE11 之外的所有浏览器中都运行良好。它显示错误:' XPathResult is undefined'。是的,我wgxpath.install.js在那之前使用过脚本。

Thanks in advance

提前致谢

回答by Eric Tedj - MSFT

Internet Explorer does not support XPATH.

Internet Explorer 不支持 XPATH。

I'd suggest using CSS selectors instead of XPath if you want it to work with IE11.

如果您希望它与 IE11 一起使用,我建议使用 CSS 选择器而不是 XPath。

If you are dead-set on using XPath, I'd suggest using an XPath javascript library (like http://code.google.com/p/wicked-good-xpath/)

如果您对使用 XPath 一窍不通,我建议您使用 XPath javascript 库(例如http://code.google.com/p/wicked-good-xpath/

Sorry for the trouble. Support for XPath in IE is currently in development.

抱歉,添麻烦了。目前正在开发 IE 中对 XPath 的支持。

If you are curious what we have planned for IE-Next, visit http://status.modern.ie/

如果您好奇我们对 IE-Next 的计划,请访问http://status.modern.ie/

回答by Swapnil

I am also facing same issue. Put following code in your HTML head section and try it.

我也面临同样的问题。将以下代码放在您的 HTML 标题部分并尝试一下。

<meta http-equiv="X-UA-Compatible" content="IE=9,chrome=1" />

回答by GongchuangSu

I faced same problem.Add following code will be useful.

我遇到了同样的问题。添加以下代码会很有用。

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

Note:IE=5,NOT OTHERS.

注意:IE=5,不是其他。