html - 哪些具体的事情会导致 IE8 触发兼​​容模式?

标签 html internet-explorer-8 ie8-compatibility-mode

我有一个应用程序在某些情况下会导致 IE8 弹出兼容性消息并以兼容模式重新加载:

a problem displaying caused internet explorer to refresh the webpage using compatibility view

这种情况很少见,据我所知不会因为元标记而发生。它作为对更改 DOM 的用户操作的响应而发生。这与以下问题相同:https://superuser.com/questions/215281/how-do-i-stop-i-e-jumping-into-compatability-view ,但我的问题是:是什么类型的事情导致了这种情况,以帮助修复它。

换句话说,看这个网站thesitewizard.com ,其中IE8兼容模式的第三个原因描述为:

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).

问题是:有哪些深不可测、未记录的原因?

最佳答案

经过长时间的调试(使用老式警报来查明失败的地方),这条看似无害的 dom 操作线是罪魁祸首:

document.getElementById("literal"+varValue).style.display = "none";

这里没有错误,显然找到了元素(即,这不是普通的空指针)。

这是一个大型应用程序,围绕这段代码进行了很多工作。我将其切换为以下内容,这显然已经阻止了这个问题:

setTimeout(function(){
           var layoutEl = document.getElementById("literal"+varValue);
           if (layoutEl)
               layoutEl.style.display = "none";
       },10)

关于html - 哪些具体的事情会导致 IE8 触发兼​​容模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9006845/

相关文章:

javascript onDOMContentLoaded 不触发

css - IE8 不透明度/过滤器 css 样式不起作用

javascript - 为什么indexOf 不能在IE8 上工作?

html - IE8 html图像对齐

javascript - Bing map 上的 HTML 框无法在 IE8 或 Firefox 中正确查看

javascript - 完成页面加载后执行功能

javascript - 在HTML表单中添加JavaScript计算功能

css - 如何让 Internet Explorer 8 支持第 n 个 child() CSS 元素?

javascript - 如何设置切换效果的样式?

internet-explorer-8 - IE8 中有切换文本大小的键盘快捷键吗?