0

由于某些未知原因,我正在处理的网站保持交叉匹配浏览器和文档模式。当我打开 IE8 开发工具时,我看到浏览器模式是 IE8,但文档模式是 IE7。

我已经进行了几次 doctype 更改,但无法让网站在文档模式的浏览器模式下自动加载,也就是 IE8。

当前的 Doctype 声明:

<%@ Page Language="vb" AutoEventWireup="true"  Src="Scripts/Splash.aspx.vb" Inherits="SplashFunctionality"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Welcome to CAE's KC-135 ATS Home</title>
<link rel="stylesheet" type="text/css" href="CSS/HomeStyles.css"/>
<link rel="stylesheet" type="text/css" href="CSS/headerStyles.css"/>
<script type="text/javascript" src="Scripts/Roladex.js"></script>
<script type="text/javascript" src="Scripts/HeaderNav.js"></script>
<script type="text/javascript" src="Scripts/HomeFunctionality.js"></script>
<script type="text/javascript" src="Scripts/JSTweener.js"></script>
</head>
<body>
4

2 回答 2

2

发生这种情况的原因通常是因为 IE 中的配置设置,它告诉它在某些条件下切换到兼容模式。这通常会在您浏览本地网络中的站点时发生——因此通常会在您测试正在开发的站点时发生。

当然,您可以通过更改配置将其关闭。但是您的用户仍然可以启用该设置,因此您需要尝试在站点内处理它。

这样做的方法是设置X-UA-Compatible元标志,您可以使用它来强制 IE 进入正确模式。

在大多数情况下,最佳设置如下:

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

将此添加到代码顶部的<head>块内。

希望有帮助。

于 2012-08-27T20:56:49.613 回答
1

To force IE the use the latest available settings on the browser you can add this to your .htaccess if you use Apache:

# ----------------------------------------------------------------------
# Better website experience for IE users
# ----------------------------------------------------------------------

# Force the latest IE version, in various cases when it may fall back to IE7 mode
#  github.com/rails/rails/commit/123eb25#commitcomment-118920
# Use ChromeFrame if it's installed for a better experience for the poor IE folk

<IfModule mod_headers.c>
  Header set X-UA-Compatible "IE=Edge,chrome=1"
  # mod_headers can't match by content-type, but we don't want to send this header on *everything*...
  <FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|oex|xpi|safariextz|vcf)$" >
    Header unset X-UA-Compatible
  </FilesMatch>
</IfModule>

More info can be found (as stated) github.com/rails/rails/commit/123eb25#commitcomment-118920

You can also add this as a regular meta tag:

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

if apache is not used.

And as a side note, I would suggest using html5 doctype:

<!doctype html>
于 2012-08-27T20:48:26.770 回答