How to force internet explorer to view a page in compartiblity mode


Use doctype and meta tags

The easiest way to tell Internet Explorer to use compatibility view is to either leave out the DOCTYPE on the web page entirely or to place anything above the DOCTYPE (including an XML declaration or comment).

Here are some examples. Each block of text is the entire web page document.

Standards View

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”&gt;
<html>
<head>
<title>Compatibility Check</title>
</head>
<body>
<h1>Compatibility View</h1>
</body>
</html>

Compatibility View

<html>
<head>
<title>Compatibility Check</title>
</head>
<body>
<h1>Compatibility View</h1>
</body>
</html>

Standards View

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”&gt;
<html>
<head>
<title>Compatibility Check</title>
</head>
<body>
<h1>Compatibility View</h1>
</body>
</html>

Compatibility View

<?xml version=”1.0″ encoding=”UTF-8″>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;
<html>
<head>
<title>Compatibility Check</title>
</head>
<body>
<h1>Compatibility View</h1>
</body>
</html>

Note, that last example should load as standards view in XHTML mode. But Internet Explorer interprets that XML declaration as requiring compatibility view.

Using HTTP Headers to Force Standards View in Internet Explorer 8 and Above

You can also use meta tags to force standards mode. The X-UA-Compatible meta tag tells Internet Explorer what view mode to use or emulate.

By setting this meta tag, you tell IE to use standards mode even if there are comments or an XML declaration above the DOCTYPE. You determine what version of Internet Explorer can best view the page, and then set the meta tags to define that version.

IE 7:

<meta http-equiv=”X-UA-Compatible” value=”IE=7″>

IE 8:

<meta http-equiv=”X-UA-Compatible” value=”IE=8″>

IE 9:

<meta http-equiv=”X-UA-Compatible” value=”IE=9″>

If a customer comes to a page with a view mode higher than it supports (e.g. an IE 7 browser viewing a page asking for IE8 view mode), it will ignore the tag and render the page the the mode it would have without the tag.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s