DOMParser is undefined in IE9

12,894

Solution 1

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

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 didn't support the DomParser object, so if IE9 is in IE7 compatibility mode, it's natural that it will stop supporting it too.

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.

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.

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).

Hope that helps.

Solution 2

I received this error, "DOMParser is undefined", on IE9 and it turned out to be an add-on that was disabled.

Name XML DOM Document Publisher Microsoft Corporation Status Enabled

Tools – Manage Add-ons – Microsoft Corporation

Share:
12,894

Related videos on Youtube

mihsathe
Author by

mihsathe

Updated on June 01, 2022

Comments

  • mihsathe
    mihsathe almost 2 years

    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.

    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. It works fine on FF and Chrome

  • mihsathe
    mihsathe almost 13 years
    I had figured the solution already. But awesome response and great suggestion for IE7.js. Thanks a ton. +1+best ans