Reputation: 6056
I have a JavaScript which works in IE7, 8 Compatibility Mode, Chrome, Firefox etc. The only thing is this script doesnt work in IE8 and IE9. Any Idea?
So, i would like to set the document compatibility mode during runtime in page ,<Head>
section. How to Conditionally set the compatibility modes?
Upvotes: 0
Views: 981
Reputation: 881
I recommend fixing your JavaScript. In the long run you'll save yourself a lot of trouble.
If your dead set on leaving your script as it is, you can use the X-UA-Compatible meta tag (see META Tags and Locking in Future Compatibility). That should make your JavaScript work (no guarantee!).
If you want to set it at run time you can declare it on your page:
<meta id="comp" http-equiv="X-UA-Compatible" runat="server" />
and set it in the code-behind
comp.Content = "IE=EmulateIE7";
Other browser simply ignore the tag however, so you can just put it on your page like this:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
Upvotes: 3