What specific things cause IE8 to trigger compatibility mode?

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)

Leave a Comment

tech