0

要强制网页以标准模式打开,我相信我需要将以下元标记添加到 head 部分。

<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">

我还在某些地方读到可能会在元标记之前添加一些其他标记,因此这可能不起作用。因此,需要设置 HTTP 响应标头,这应该可以工作。我也这样做了,并使用 IE 开发人员工具验证了响应现在包含标题“X-UA-Compatible”,值为“IE=Edge,chrome=1”(无法上传屏幕截图,声誉不足)

但是浏览器模式仍然是 IE9 Compat View,文档模式是 IE8 标准。还有什么我需要做的吗?

以下是html片段

<!DOCTYPE html>
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO 8859-1"%>
    <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
    <%
        String contextPath = request.getContextPath();
    %>
    <html>
        <head>
            <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
                .
                .
        </head>
    </html>
4

1 回答 1

1

确保您有一个有效的文档类型,并且文档类型之前没有空格。此外,<html>标签不应有任何 xmlns 属性,例如xmlns="http://www.w3.org/1999/xhtml",如果您使用 HTML5 doctype

<!DOCTYPE html> 
    <html> 
        <head> 
        ...
于 2014-04-25T10:33:50.443 回答