为什么我会在 IE8 中触发怪异模式?
我正在开发一个页面,当我加载到 IE8 并查看开发人员工具时,它告诉我页面默认为怪异模式。
我有一个严格的 DTD:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
我什至继续放入显式标准开关,尽管我认为我不需要这样做:
<meta http-equiv="X-UA-Compatible" content="IE=8" />
我不明白为什么页面默认不是 IE8 标准?
我唯一能想到的是,要访问此页面,我首先必须登录应用程序,并且我必须遍历的第一个页面是旧的怪癖模式页面。 IE 是否在服务器级别决定使用哪种模式,还是应该逐页决定?
谢谢!
I'm working on a page that, when I load into IE8 and view the developers tools it tells me that page default is quirks mode.
I've got a strict DTD:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
I even went ahead and put in the explicit standards switch, though I didn't think I'd need to:
<meta http-equiv="X-UA-Compatible" content="IE=8" />
I can't understand why page default isn't IE8 standards?
Only thing I can think of is that to get to this page, I first have to log in to an application and the first pages I must traverse are old quirks mode pages. Does IE decide on which mode to use at a server level, or is it supposed to decide page by page?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常不会。 兼容性视图列表,这是特定于站点的,但这只会将您踢回 IE7 样式标准模式,而不是 IE5.5 样式怪异模式。
只要 DOCTYPE 是页面上的第一个内容,您的代码在其他方面看起来就不错。如果文档类型之前有注释、PI、XML 声明(IE8 之前的版本)或任何非空白文本内容,IE 将强制
document.compatMode= 'BackCompat'
。如果控制字符已潜入,而您在文本编辑器中看不到,则可以做到这一点。问题页面示例?
Not generally, no. There is the ugliness of the compatibility view list, which is site-specific, but that only kicks you back to IE7-style-Standards Mode, not IE5.5-style-Quirks-Mode.
Your code otherwise looks OK, as long as that DOCTYPE is the very first thing on the page. IE will be forced to
document.compatMode= 'BackCompat'
if there is a comment, PI, XML declaration (prior to IE8) or any non-whitespace textual content before the doctype. If a control character has snuck in that you can't see in your text editor, that could do it.Example problem page?