Change IE9 Document Mode to IE9 Standards

2019-02-19 21:45发布

问题:

How can I force my IE9 to have the Document Mode of IE9 Standards?

Now, I have this meta content, but it seems it's not working.

 <html>
    <head>
     <meta http-equiv="X-UA-Compatible" content="IE=9" />

Also, how can I know if my Document Mode already changed?

Thank you very much.

回答1:

You state that the browser is defaulting to Quirks mode.

The correct solution to getting out of Quirks mode is to use a DOCTYPE.

Make sure that your HTML code starts with the following line:

<!DOCTYPE html>

This should be the first line of code, above the <html> tag.

The X-UA-Compatible flag is good thing to have, but isn't relevant to your problem in this case. It tells IE to switch between various compatibility modes, but Quirks mode is a whole separate thing, and is controlled by the existence or not of the doctype.

You should keep the X-UA-Compatible flag, although as I said in the comments, you would be better to set it to IE=edge rather than IE=9, otherwise you're going to have problems with IE10 and later.

Hope that helps.

[EDIT]

We have now established that the OP's site is running in a frame, inside another site that is in quirks mode.

This is a big problem because IE will render all frames in the same mode, so if the parent site is stuck in quirks mode then his site will also be stuck in quirks mode.

There is pretty much nothing that can be done about this, other than converting one or other site to be in the same mode as the other.

Converting the new code to run in quirks mode might be possible, but is very risky; I would strongly recommend against it. In any case, I would need to spend time studying the whole of your source code before I'd even be able to say whether it's possible or not, let alone how much work it is.

Converting the old code to run in standards mode is likely to be more achieveable. Again, it depends on how large the code base is, but the main point is that you don't need to worry about the conversion breaking due to unsupported features, because the site is already running in an old mode; moving to the newer mode might require some changes, but at least you can be fairly sure from the start that it is possible.

The only other option you have is to change your site so that instead of being in a frame, it pops out into its own separate window (or tab). This way, it can stay in standards mode and the old site can stay in quirks mode. This is the only option you have that doesn't involve a lot of work.

I guess the ultimate message from all of this is that quirks mode is a terrible thing. The world would be a much better place if all those old corporate systems out there running in quirks mode would be upgraded to use standards mode. It really is a lot less effort than people think, and will prevent nasty situations like this one.



回答2:

use content="IE=edge" instead of IE=9 this will force your IE browser to stick to latest available