How do I get IE9 to use standards compliant mode w

2020-03-01 05:30发布

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条回答
叼着烟拽天下
2楼-- · 2020-03-01 05:59

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.

查看更多
混吃等死
3楼-- · 2020-03-01 06:03

Try adding this:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

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.

查看更多
别忘想泡老子
4楼-- · 2020-03-01 06:21

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

查看更多
一夜七次
5楼-- · 2020-03-01 06:24

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:

<%
' some asp code
%>
<!DOCTYPE html>
<!-- rest of file -->

Consider changing it to this:

<%
' some asp code
%><!DOCTYPE html>
<!-- rest of file -->

This worked for me even with @Import statements before the initial asp block:

<%@ Import Namespace="System.Text.RegularExpressions" %>
<%
' some asp code
%><!DOCTYPE html>
<!-- rest of file -->
查看更多
登录 后发表回答