Why does webpage display in IE8 browser mode and IE7 document mode?

穿精又带淫゛_ 提交于 2020-01-06 20:02:03

问题


For some unknown reason the site im working on keeps cross matching browser and document mode. When i open IE8 dev tools i see that browser mode is IE8 but document mode is IE7.

I've made several doctype changes but am unable to get the site to automatically load in the browser mode for the document mode also namely IE8.

Current Doctype declaration:

<%@ 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>

回答1:


The reason this happens is typically because of a config setting in IE, which tells it to switch into compatibility mode under certain conditions. This is often set to happen when you browse a site in your local network -- so it often happens when you are testing a site you're developing.

You can, of course, switch it off by changing the config. But it's still possible for your users to have that setting turned on, so you need to try to deal with it within the site.

The way to do this is to set the X-UA-Compatible meta flag, which you can use to force IE into the correct mode.

In most cases, the best setting for this is as follows:

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

Add this to the top of your code, inside the <head> block.

Hope that helps.




回答2:


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>


来源:https://stackoverflow.com/questions/12149353/why-does-webpage-display-in-ie8-browser-mode-and-ie7-document-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!