为什么 IE9 在我的网站上切换到兼容模式?
我刚刚安装了 IE9 beta,并且在我创建的特定站点 (HTML5) 上,IE9 会跳转到兼容模式,除非我手动告诉它不要这样做。我尝试删除网站的几个部分,但没有任何变化。包括删除所有 CSS 包含内容。在我的其他一些网站上,一切都很好。
另外,不要手动设置它,因为 IE9 会记住用户设置,并且您无法将其恢复为自动(或者至少我还没有找到如何操作,甚至没有通过隐私浏览和清空缓存)
。跳转到兼容模式的网站:http://alliancesatwar.com/guide/
正确呈现的一个: http://geuze.name/basement/ (我不能发布超过1 个超链接)
两者都使用相同的doctype
。这些网站有很多共同点(除了外观),使用相同的基本模板(编码、元标记、文档类型和相同的 javascript),
如果有人能为我提供答案,那就太好了!在 IE7 模式下呈现的 HTML5 网站非常……蹩脚。
I have just installed IE9 beta and on a specific site I created (HTML5) IE9 jumps to compatibility mode unless I manually tell it not to. I have tried removing several parts of the website but no change. Including removing all CSS includes. On some other website of me it goes just fine.
Also, don't set it manually because then IE9 remembers the user setting and you can't turn it back to automatic (or at least I haven't found how, not even via private browsing and emptying cache)
Anyway. The site where it jumps to compatibility mode: http://alliancesatwar.com/guide/
One where it renders correct: http://geuze.name/basement/ (I can't post more than 1 hyperlink)
Both use the same doctype
and all. Those sites have a lot in common(apart from appearance) using the same basic template(encoding, meta tags, doctype and the same javascript)
It would be great if someone has an answer for me! An HTML5 website that renders in IE7-mode is pretty... lame.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
对我来说适用于 IE9 文档模式。
如果没有
X-UA-Compatible
标头/元来设置显式 documentMode,您将获得基于以下内容的模式:您可以从“工具 ->”更改这些设置。 IE 菜单中的“兼容性视图设置”。当然,该菜单现在已被偷偷隐藏,因此在按 Alt 之前您不会看到它。
作为网站作者,如果您确信自己的网站符合标准(在其他浏览器中呈现良好,并使用功能嗅探来决定使用哪些浏览器解决方法),我建议使用:
或 HTTP 标头:
来获取最新的无论使用什么 IE 版本,都会使用渲染器。
Works in IE9 documentMode for me.
Without a
X-UA-Compatible
header/meta to set an explicit documentMode, you'll get a mode based on:You can change these settings from ‘Tools -> Compatibility view settings’ from the IE menu. Of course that menu is now sneakily hidden, so you won't see it until you press Alt.
As a site author, if you're confident that your site complies to standards (renders well in other browsers, and uses feature-sniffing to decide what browser workarounds to use), I suggest using:
or the HTTP header:
to get the latest renderer whatever IE version is in use.
我把
第一件事放在后面
(我在某个地方读到过,我不记得了)
我不敢相信它确实有效!
I put
first thing after
(I read it somewhere, I can't recall)
I could not believe it did work!!
要强制 IE 以 IE9 标准模式呈现,您应该使用
某些条件可能会导致 IE9 跳转到兼容模式。默认情况下,这可能发生在 Intranet 站点上。
To force IE to render in IE9 standards mode you should use
Some conditions may cause IE9 to jump down into the compatibility modes. By default this can occur on intranet sites.
我已经在单独的 StackOverflow 线程上发布了此评论,但认为值得在这里重复:
对于我们内部的 ASP.Net 应用程序,在网页上的 web.config 中添加“X-UA-Compatible”标签或者在代码隐藏中完全没有区别。
唯一对我们有用的是在 IE8 中手动关闭此设置:
(叹气。)
这个问题似乎只发生在 IE8 和 IE8 上。 Intranet 站点上的 IE9。外部网站可以正常工作并使用正确的 IE8/9 版本,但对于内部网站,IE9 突然决定它实际上是 IE7,并且没有任何 HTML 5 支持。
不,我也不太明白这个逻辑。
我不情愿的解决方案是测试浏览器是否支持 HTML 5(通过创建画布并测试它是否有效),如果无效则向用户显示此消息:
它不是特别用户友好,但让用户关闭这个烦人的设置
似乎是让他们正确运行内部 HTML 5 Web 应用程序的唯一方法。
或者让用户使用 Chrome。 ;-)
I've posted this comment on a seperate StackOverflow thread, but thought it was worth repeating here:
For our in-house ASP.Net app, adding the "X-UA-Compatible" tag on the web page, in the web.config or in the code-behind made absolutely no difference.
The only thing that worked for us was to manually turn off this setting in IE8:
(Sigh.)
This problem only seems to happen with IE8 & IE9 on intranet sites. External websites will work fine and use the correct version of IE8/9, but for internal websites, IE9 suddenly decides it's actually IE7, and doesn't have any HTML 5 support.
No, I don't quite understand this logic either.
My reluctant solution has been to test whether the browser has HTML 5 support (by creating a canvas, and testing if it's valid), and displaying this message to the user if it's not valid:
It's not particularly user-friendly, but getting the user to turn off this annoying setting
seems to be the only way to let them run in-house HTML 5 web apps properly.
Or get the users to use Chrome. ;-)
http://www.HTML-5.com/index.html 的网站确实具有 X-UA-Compatible 元标记,但仍进入兼容性视图,如地址栏中的“撕裂页面”图标所示。如何获得强制 IE 9(最终版本 9.0.8112.16421)在标准模式下渲染页面的菜单选项?我尝试右键单击那个撕裂的页面图标以及“Alt”键技巧来显示 Rene Geuze 提到的其他菜单选项,但这些都不起作用。
The site at http://www.HTML-5.com/index.html does have the X-UA-Compatible meta tag but still goes into Compatibility View as indicated by the "torn page" icon in the address bar. How do you get the menu option to force IE 9 (Final Version 9.0.8112.16421) to render a page in Standards Mode? I tried right clicking that torn page icon as well as the "Alt" key trick to display the additional menu options mentioned by Rene Geuze, but those didn't work.
顺便说一句,在更现代的网站上,如果您按照样板文件在 html 标记上使用条件语句,这将由于某种原因导致 ie9 默认为兼容模式。这里的解决方法是将条件语句从 html 标记中移出,并将它们添加到 body 标记中,换句话说,将它们添加到 head 部分之外。这样,您仍然可以在样式表中使用这些类来针对较旧的浏览器。
As an aside on more modern websites, if you are using conditional statements on your html tag as per boilerplate, this will for some reason cause ie9 to default to compatibility mode. The fix here is to move your conditional statements off the html tag and add them to the body tag, in other words out of the head section. That way you can still use those classes in your style sheet to target older browsers.
对我来说看起来不错:
您确定没有全局设置或其他什么?这是 Windows 7 上测试版的全新安装。开发人员工具报告该页面默认为 IE9 标准模式。
Looks fine to me:
You're sure you didn't on the settings globally or something? This is a clean installation of the beta on Windows 7. The developer tools report that the page is defaulting to IE9 Standard Mode.
我最近必须解决这个问题,这就是我所做的:
首先,这个解决方案是围绕调整 Apache 服务器的。
第二个主要想法是 IE9 中存在一个错误,这意味着元标记将不起作用,而不是此解决方案,请尝试此
取消注释/或添加以下行
添加以下行
保存/重新启动您的 Apache 服务器,
I recently had to resolve this issue and here's what I did :
First of all, this solution is around tuning Apache server.
Second main think is that there's a bug in the IE9 which means that the meta tag will not work, instead of this solution try this
uncomment/or add the following line
add the following lines
save/restart your Apache server,