Force IE9 into compatibility mode using javascript

Serhiy picture Serhiy · Mar 29, 2012 · Viewed 17.2k times · Source

I have a frame that needs compatibility mode but parent frame seems to be setting it so the following tag inside the frame does nothing.

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

Is there anyway to apply compat mode to only the frame, or have the frame apply compat mode to the parent frame.

Was thinking if there is a javascript method to switch modes I could apply it to the parent frame from the child frame.

Answer

Serhiy picture Serhiy · Oct 11, 2012

So here's what I've gathered.

The only thing that seems to work is the meta tag way.

However, it doesn't appear to work in frames as IE9 has disabled the ability of one frame to be of different type than another.

The meta tag also can't be preceded by script or link tags, only and other meta tags from what I've noticed, otherwise it fails as well.

TEST CASE:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <title>Test test</title>
        <meta name="keywords" content="keywords, keyword, keyword phrase, etc.">
        <!--<link href="test.css" rel="stylesheet" type="text/css" />-->
        <!--<script type="text/javascript">alert('test');</script>-->
        <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    </head>
    <body>
        inline-block <div style="display:inline-block">test</div>
    </body>
</html>