Disable Compatibility View Through Code In IE?

2020-07-05 19:55发布

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...

Browser Mode: IE9 Compat View
Document Mode: IE7 Standards

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

<!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>.

Any ideas?

4条回答
Ridiculous、
2楼-- · 2020-07-05 20:29

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.

查看更多
对你真心纯属浪费
3楼-- · 2020-07-05 20:35

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:

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

Hope this helps.

查看更多
Explosion°爆炸
4楼-- · 2020-07-05 20:48

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

Include this and IE will render as in IE9 mode:

<meta http-equiv="X-UA-Compatible" content="IE=9" />
查看更多
虎瘦雄心在
5楼-- · 2020-07-05 20:54

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

insert meta tag in header HTML:

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

and set the equivalant header:

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');

solution in this link :

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

Thanks.

查看更多
登录 后发表回答