Friday, July 15, 2011

IE8 Compatibility, and script and meta tags

When the ticker we had used for our application suddenly stopped scrolling on IE8 for some of the machines of the team-mates, we had a tough time debugging and figuring out. There was no change at all in the ticker code since the previous release, and the bloody thing worked on another installation of IE8 with the same version.

Doing a diff against all files changed between the time the ticker changed from ticking everywhere to ticking on a few installations of IE8 and everywhere else revealed a hack to emulate IE7 using IE8's compatibility mode, and the cause for the problem became apparent.

There was a meta tag that did the compatibility trick, per one of the options at the MSDN blog here :
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
The reason it did work on some installations (on some computers) of IE8 was because the Compatibility View was enabled for those setups. For the ones it did not work, it was because the meta tag came after a script tag, in which case the compatibility mode does not work.
<head>
<script></script>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"></meta>
</head>
The solution was simple, to put the meta tag before any script/css tag in the code; even an empty script tag causes the meta tag to not work.


No comments:

Post a Comment