Force Internet Explorer 9 to use IE 9 Mode

2019-03-09 07:35发布

I'm using the HTML5 doctype with X-UA-Compatible meta tag near the top:

<!DOCTYPE html>
<!--[if lt IE 7]> <html lang="en-us" class="ie6"> <![endif]-->
<!--[if IE 7]>    <html lang="en-us" class="ie7"> <![endif]-->
<!--[if IE 8]>    <html lang="en-us" class="ie8"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en-us"> <!--<![endif]-->
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    ...

But Internet Explorer 9 for some users is rendering the page in compatibility view. I suspect it's because they have the "Display all websites in Compatibility View" setting turned on. Is there a way to force IE9 to use IE9 Browser and Document Mode?

7条回答
贼婆χ
2楼-- · 2019-03-09 07:59

It turns out that the solution is to set X-UA-Compatible in the HTTP header and not in the HTML:

 X-UA-Compatible: IE=edge,chrome=1

This will force Internet Explorer to use the latest rendering engine, even if "Display all websites in Compatibility View" is turned on.

查看更多
我想做一个坏孩纸
3楼-- · 2019-03-09 08:03

@netzaffin is right - if X-UA-Compatible is the first meta tag in HEAD section, IE9 works.

查看更多
我欲成王,谁敢阻挡
4楼-- · 2019-03-09 08:06

It's also working with this in <head> in html:

  <meta http-equiv="X-UA-Compatible" content="IE=9">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
查看更多
We Are One
5楼-- · 2019-03-09 08:08

The X-UA-COMPATIBLE meta tag has to be the first tag inside the head, or else it will not work. See this answer: https://stackoverflow.com/a/22233206/3329906.

All this http header stuff is overkill.

查看更多
来,给爷笑一个
6楼-- · 2019-03-09 08:15

Only adding

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

will do ;)

For eg:

<!DOCTYPE html>
<html lang="en-US" class="css3transitions"> 
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
查看更多
Fickle 薄情
7楼-- · 2019-03-09 08:21

please append in head section of your website, hope it helps.

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta http-equiv="X-UA-Compatible" content="IE=5, IE=7, IE=8, IE=9, IE=10" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE10" />
查看更多
登录 后发表回答