根据 MSDN,我需要强制标准兼容模式就是包含 HTML 5 文档类型:
http://msdn.microsoft.com/en-us/library/gg699338%28v=vs.85%29.aspx
当远程提供标记时它可以工作。问题是当我采用相同的标记并从本地运行的 apache 服务器提供它时。 IE9默认为怪异模式,兼容性视图按钮消失。
我在本地进行了大量开发,如果我只能在远程服务时在 IE 中测试我的代码,那就达不到目的了。提前致谢。
According to MSDN, all I need to force standards compliant mode is to include the HTML 5 doctype:
http://msdn.microsoft.com/en-us/library/gg699338%28v=vs.85%29.aspx
And it works when the markup is served remotely. The problem is when I take identical markup and serve it up from an apache server running locally. IE9 defaults to quirks mode, and the compatibility view button goes away.
I do a lot of development locally, and it defeats the purpose if I can only test my code in IE when it's served remotely. Thanks in advance.
发布评论
评论(4)
使用
并添加
到 HTML 页面的
部分。它将强制 Internet Explorer 使用 IE 标准模式。
Use
<!DOCTYPE html>
and add
<meta http-equiv="X-UA-Compatible" content="IE=9">
to the
<head>
section of your HTML page. It will force Internet Explorer to use IE standards mode.尝试添加以下内容:
在页面顶部。我不确定如果你尝试过的其他方法不能在本地工作,那么这是否会在本地工作......但值得一试。
Try adding this:
At the top of your page. I'm not sure if that will work locally if the other you tried didn't... but it's worth a go.
我也有同样的问题。我的 aspx 文件中有 HTML5 文档类型,但它仍然以 IE7 模式呈现。我修复了它,没有设置 HTML4.01 Strict,也没有元 http-equiv。
我的问题是我有一个 ASP 标记,然后文档类型位于单独的行中。 IE9 希望文档类型位于第 1 行,而不是其他地方。
因此,如果你有这个:
考虑将其更改为:
即使在初始 asp 块之前使用 @Import 语句,这对我也有效:
I had this same problem. I had the HTML5 doctype on my aspx file, but it still rendered in IE7 mode. I fixed it without setting HTML4.01 Strict, and without meta http-equiv.
My problem was that I had an ASP tag, then the doctype in a separate line. IE9 wants the doctype to be on line 1 and nowhere else.
So if you have this:
Consider changing it to this:
This worked for me even with @Import statements before the initial asp block:
请参阅本文档中的“IE Windows 特殊:xml prolog”部分:
http://www.quirksmode .org/css/quirksmode.html
DOCTYPE 之前的任何内容都会导致其切换到 Quirks 模式
See the "IE Windows special: the xml prolog" section in this document:
http://www.quirksmode.org/css/quirksmode.html
Anything before the DOCTYPE will cause it to switch to Quirks mode