I've got an app that under some circumstances causes IE8 to popup the compatibility message and reload in compat mode:
a problem displaying caused internet explorer to refresh the webpage using compatibility view
This is rare, and does not occur due to the meta-tags, as far as I can tell. It happens as a response to user action that alters the DOM. This is the same problem as: https://superuser.com/questions/215281/how-do-i-stop-i-e-jumping-into-compatability-view, but my question is: What types of things cause this, as an aid in fixing it.
Put another way, see this site thesitewizard.com, where a third cause of compatibility mode in IE8 is described as:
and, on occasion, for some other unfathomable, undocumented reason, on pages that are validated as standards-compliant (or, at least, it does this in Release Candidate 1).
And the question is: What unfathomable, undocumented reasons?
Open up Internet Explorer (IE 11) Press the Alt key on your keyboard, this will make a menu bar appear. Click on the Tools menu tab. Select the Compatibility View settings option.
In your Internet Explorer web browser, press F12 to open the Developer Tools window. Click Browser Mode and select the version of your web browser. Click Document Mode, and select the Internet Explorer standards for your Internet Explorer release.
After a long debugging session (using old school alerts to pinpoint what was failing where), this seemingly innocous line of dom manipulation was the culprit:
document.getElementById("literal"+varValue).style.display = "none";
There was no error here, and the element was apparently found (ie, this is not a garden variety null pointer).
This is a large scale app, and there is a lot going on around this code. I switched it to the following, and this apparently has prevented the issue:
setTimeout(function(){ var layoutEl = document.getElementById("literal"+varValue); if (layoutEl) layoutEl.style.display = "none"; },10)
The following content comes from an MSDN article "Controlling default rendering".
These links provide additional info that describes how Internet Explorer determines the appropriate document mode for a webpage:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With