首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >页面未在ie8中呈现。仅在兼容性视图模式下呈现

页面未在ie8中呈现。仅在兼容性视图模式下呈现
EN

Stack Overflow用户
提问于 2013-08-22 21:47:17
回答 1查看 1.1K关注 0票数 1

我在IE8+浏览器中呈现页面时遇到了问题,它在FireFox上工作得很好。如果我保持下面的代码,那么它不会在IE8+中呈现页面。它只在兼容视图模式下渲染,而不在普通模式下渲染。

代码语言:javascript
复制
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!--[if lt IE 7]><html lang="en" class="no-js lt-ie10 lt-ie9 lt-ie8 lt-ie7" xml:lang="en" xmlns:fb="http://www.facebook.com/2008/fbml"> <![endif]-->
<!--[if IE 7]><html lang="en" class="no-js lt-ie10 lt-ie9 lt-ie8" xml:lang="en" xmlns:fb="http://www.facebook.com/2008/fbml"> <![endif]-->
<!--[if IE 8]><html lang="en" class="no-js lt-ie10 lt-ie9" xml:lang="en" xmlns:fb="http://www.facebook.com/2008/fbml"> <![endif]-->
<!--[if IE 9]><html lang="en" class="no-js lt-ie10" xml:lang="en" xmlns:fb="http://www.facebook.com/2008/fbml"> <![endif]-->
<!--[if gt IE 9]><!--><html lang="en" class="no-js" xmlns="http://www.w3.org/1999/html" xml:lang="en" xmlns:fb="http://www.facebook.com/2008/fbml"> <!--<![endif]-->

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <link type="text/css" rel="stylesheet" href="./public/css/styles.css">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.0/jquery.validate.js"></script>
    <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.js"></script>
    <script type="text/javascript" src="./public/js/myjs.js"></script>
    </head>
    <body>

    </body>

    </html>

但是如果我像下面这样修改代码。然后,它将正确呈现,而无需切换到IE8+中的兼容性视图模式。

代码语言:javascript
复制
<!--[if lt IE 7]><html lang="en" class="no-js lt-ie10 lt-ie9 lt-ie8 lt-ie7" xml:lang="en" xmlns:fb="http://www.facebook.com/2008/fbml"> <![endif]-->
<!--[if IE 7]><html lang="en" class="no-js lt-ie10 lt-ie9 lt-ie8" xml:lang="en" xmlns:fb="http://www.facebook.com/2008/fbml"> <![endif]-->
<!--[if IE 8]><html lang="en" class="no-js lt-ie10 lt-ie9" xml:lang="en" xmlns:fb="http://www.facebook.com/2008/fbml"> <![endif]-->
<!--[if IE 9]><html lang="en" class="no-js lt-ie10" xml:lang="en" xmlns:fb="http://www.facebook.com/2008/fbml"> <![endif]-->
<!--[if gt IE 9]><!--><html lang="en" class="no-js" xmlns="http://www.w3.org/1999/html" xml:lang="en" xmlns:fb="http://www.facebook.com/2008/fbml"> <!--<![endif]-->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <link type="text/css" rel="stylesheet" href="./public/css/styles.css">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.0/jquery.validate.js"></script>
    <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.js"></script>
    <script type="text/javascript" src="./public/js/myjs.js"></script>
    </head>
    <body>

    </body>

    </html>

这两个代码有什么不同?

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2013-08-22 21:50:38

<!DOCTYPE HTML应该在文档的第一行,以便切换到标准(即不兼容)模式。

如果你真的需要兼容模式,你可以在文件的开头添加空行,或者像<!-- Yes, I like quirksmode -->这样的注释来使你的操作更明确。

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18382313

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档