Monday, July 4, 2011

Force IE to render in IE standard mode

Forcing a document mode

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

or the HTTP header:
 
X-UA-Compatible: IE=Edge

to get the latest renderer whatever IE version is in use.


You can force a particular document mode by using the X-UA-Compatible HTTP header or by using the<meta> tag equivalent:<meta http-equiv="X-UA-Compatible" content="IE=IEVersion">


There are several different possible values for the IE version in this field and they don’t necessary map to the three document modes:
Edge – always put the document into the most recent document mode available. Doctype is ignored. For Internet Explorer 8, this forces the document mode to IE8 standards all the time. Be careful when using this because when Internet Explorer 9 comes out, this will force the page into IE9 standardsmode.
EmulateIE8 – if a doctype is present, set the document mode to IE8 standards and otherwise set the document mode to IE5.
EmulateIE7 – if a doctype is present, set the document mode to IE7 standards and otherwise set the document mode to IE5.
8 – force document mode to be IE8 standards. Doctype is ignored.
7 – force document mode to be IE7 standards. Doctype is ignored.
5 – force document mode to be IE5. Doctype is ignored.

For example, to make the document mode behave as it would in Internet Explorer 7, you can use the following:<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">


Whereas to force IE7 standards mode regardless of doctype, use this:<meta http-equiv="X-UA-Compatible" content="IE=7">


You are not required to have an X-UA-Compatible field set on pages. If not present, the default isEmulateIE8

No comments:

Post a Comment