Html 通过 IE 中的代码禁用兼容性视图?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8650557/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 12:11:39  来源:igfitidea点击:

Disable Compatibility View Through Code In IE?

htmlcssinternet-explorerstandards

提问by Aaron Brewer

I for some reason am calling a doctype preferably XHTML 1.0 Transitional, and for some reason every single time I open it in Internet Explorer I get...

出于某种原因,我最好将文档类型称为 XHTML 1.0 Transitional,出于某种原因,每次我在 Internet Explorer 中打开它时,我都会得到...

Browser Mode: IE9 Compat View
Document Mode: IE7 Standards

浏览器模式:IE9 Compat 查看
文档模式:IE7 标准

I'll even include what my doctype looks like with the beginning of my head tags:

我什至会在 head 标签的开头包含我的文档类型:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>

And yes, I do close <body>and <html>.

是的,我确实关闭<body><html>

Any ideas?

有任何想法吗?

回答by Sologoub

Here's the documentation you are looking for: http://msdn.microsoft.com/en-us/library/cc288325(v=vs.85).aspx

这是您正在寻找的文档:http: //msdn.microsoft.com/en-us/library/cc288325(v=vs.85).aspx

Include this and IE will render as in IE9 mode:

包含此内容,IE 将呈现为 IE9 模式:

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

回答by Erik Funkenbusch

By default, IE will render in compatibility mode for websites on the same subnet as the client. You can fix this by either turning off this feature in IE by going to Tools->Compatibility View Settings and unchecking Display Intranet sites in compatibility mode, or by including the meta tag that Sologoub mentioned.

默认情况下,IE 将以兼容模式呈现与客户端位于同一子网上的网站。您可以通过转到“工具”->“兼容性视图设置”并取消选中“在兼容模式下显示 Intranet 站点”来关闭 IE 中的此功能,或者通过包含 Sologoub 提到的元标记来解决此问题。

回答by longga

I have this issure too. And I found a solution :

我也有这个问题。我找到了一个解决方案:

insert meta tag in header HTML:

在标题 HTML 中插入元标记:

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

and set the equivalant header:

并设置等效标题:

header('X-UA-Compatible: IE=Edge');

header('X-UA-Compatible: IE=Edge');

Or if you use Zend Framework (or any framework for that matter), something like this will do Zend_Controller_Front::getInstance()->getResponse()->setHeader('X-UA-Compatible', 'IE=Edge');

或者,如果您使用 Zend 框架(或任何与此相关的框架),则类似这样的事情 Zend_Controller_Front::getInstance()->getResponse()->setHeader('X-UA-Compatible', 'IE=Edge');

solution in this link :

此链接中的解决方案:

http://www.enrise.com/2012/03/internet-explorer-9-compatibility-view-list/

http://www.enrise.com/2012/03/internet-explorer-9-compatibility-view-list/

Thanks.

谢谢。

回答by gamut

Sometimes you need to be a bit more comprehensive so that you target all the possible user overrides. Certainly for single-page apps like Meteor:

有时您需要更全面一些,以便您针对所有可能的用户覆盖。当然对于像 Meteor 这样的单页应用程序:

<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE; Chrome=1" />

Hope this helps.

希望这可以帮助。