IE9中未定义DOMParser [英] DOMParser is undefined in IE9

查看:338
本文介绍了IE9中未定义DOMParser的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到IE9的一个非常奇怪的错误.当我在localhost的jsp页面中使用DOMParser时,它运行得很好,并给出了正确的结果.

I am getting a very weird kind of error with IE9. When I use a DOMParser from within a jsp page on localhost, it runs perfectly fine and gives the proper result.

但是令人震惊的是,当我在普通HTML文件(不在服务器上.从文件系统上)中使用DOMParser时,我得到了"DOMParser is undefined"的烦人消息.这是什么以及如何使它工作?谢谢.

But Shockingly, when I use DOMParser inside a normal HTML file (Not on the server. From the file system), I get this annoying message of "DOMParser is undefined" .. What is this and how can I make it work? Thank You.

P.S.在FF和Chrome上正常运行

P.S. It works fine on FF and Chrome

推荐答案

我会说这几乎可以肯定是浏览器在浏览本地URL时以兼容模式运行的.

I would say that this is almost certain to be the browser running in compatibility mode when browsing local URLs.

您可以通过打开开发工具(按F12)并查看右上角进行检查.如果它说它处于IE7模式,则说明您已找到问题.将其切换回普通IE9模式,它应该正确显示.

You can check this by opening the dev tools (press F12) and looking in the top right corner; if it says it's in IE7 mode, then you've found the problem. Switch it back to normal IE9 mode and it should come right.

IE7不支持DomParser对象,因此,如果IE9处于IE7兼容模式,很自然它将停止支持它.

IE7 didn't support the DomParser object, so if IE9 is in IE7 compatibility mode, it's natural that it will stop supporting it too.

好,那就是它正在做的.但是为什么要这样做呢? IE(IE8和IE9)中都有一个配置设置,该设置指定浏览本地Intranet上的站点时浏览器应进入兼容模式.存在此设置的原因是,允许具有针对IE的较早版本设计的内部站点的公司升级到新版本,而不会破坏这些站点.它的目的是使那些不想在损坏的版本足够好时不花钱修复某些事情的公司类型变得更容易.

Ok, so that's what it's doing. But why is it doing this? There is a config setting in IE (both IE8 and IE9) which specifies that the browser should fall into compatibility mode when browsing sites on the local intranet. The reason for this setting existing is to allow companies who have internal sites designed for older versions of IE to upgrade to a new version without breaking those sites. It's intended to make like easier for corporate types who would rather not spend money fixing something when the broken version is good enough.

但这对我们其他人来说都是痛苦的事.

But it's a pain in the rear for the rest of us.

很明显,如果您的站点位于公共互联网上,则该标志将不受此标志的影响,除非您尝试从自己的PC上的localhost对其进行处理.因此,为您提供的解决方案是只需在浏览器中关闭此配置设置,而不必理会它.

Obviously, if your site is on the public internet, it won't be affected by this flag, except when you're trying to work on it from localhost on your own PC. Therefore, the solution for you is to simply turn off this config setting in the browser and forget about it.

当然,事实仍然是IE7的用户仍会在您的网站上遇到此问题,因为他们的浏览器不支持您正在使用的功能.您可以放弃对IE7的支持,并告诉那些用户升级.但是,如果您想支持IE7用户,我相信Dean Edwards的 IE7.js 脚本允许浏览器模拟此功能(以及Microsoft忘记的许多其他功能).

Of course, the fact remains that users of IE7 will still have this problem with your site, as their browser doesn't support the feature you're using. You could just drop support for IE7, and tell those users to upgrade. But if you want to support IE7 users, I believe that Dean Edwards' IE7.js script allows the browser to emulate this feature (along with a bunch of other stuff that Microsoft forgot).

希望有帮助.

这篇关于IE9中未定义DOMParser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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