About the introduction of content="IE=edge,chrome=1" - let web pages be rendered in Chrome first

Recently, I learned a little about the waterfall tree. When I looked at the Wookmark jQuery plugin , I noticed that there is such a sentence in the meta:

 

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

 

Among them, http-equiv=”X-UA-Compatible” is a special mark for IE8, which is used to specify the rendering method of Internet Explorer 8 browser to simulate a specific version of IE browser, so as to solve the compatibility problem of IE browser. .

The code used by CSS hackers to simulate the rendering method of IE7:

 

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

 

What makes me curious is that the paragraph "content="IE=edge,chrome=1"" in the code mentioned in the first paragraph of the article literally means that IE uses chrome's rendering method? Or let IE's skin use the Chrome kernel in the background?

 

Dual-core browsers use the webkit kernel by default

<meta name="renderer" content="webkit" />

 

Google Chrome Frame

Check it out, this is a Google Chrome Frame " Google Chrome Browser Frame - GCF " developed by Google . Using GCF can make the appearance of the user's IE browser unchanged, but the user actually uses the Chrome kernel when browsing the web, and supports IE6/7/8 of Windows XP and above systems.

The code mentioned in the first paragraph specifies that the page uses the Chrome kernel for rendering, provided that the user must have Google Chrome Frame installed .

The official definition of it:

  • Launch instantly using open web technologies such as the HTML5 canvas tag, even those not yet supported by Internet Explorer 6, 7 or 8.
  • Take advantage of JavaScript performance enhancements to make applications faster and more responsive.

So this code can be interpreted as: if GCF is installed, use GCF to render the page ""chrome=1"" , if GCF is not installed, use the highest version of IE kernel to render ""IE=edge"" .

html5 validation for w3.org

However, the next problem comes again, under w3.org's html5 validation tool:

Either way, we can configure http equiv rules on the server side for all three mainstream servers:

1. apache server

Make sure mod_headers and mod_setenvif are available, then add the following rules in httpd.conf "The new version of Apache configuration file is apache2.conf" or in .htaccess:

<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
BrowserMatch chromeframe gcf
Header append X-UA-Compatible "chrome=1" env=gcf
</IfModule>
</IfModule>

 

2. Windows Server on IIS7 or higher version server

Just modify the web.config file and add the following information:

<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name = "X-UA-Compatible" value = "chrome=1" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>

3、Nginx服务器

只需要找到ginx.conf并编辑,在server { }区域里(最好是闭合符前面起一行)添加下列代码即可:

add_header "X-UA-Compatible" "IE=Edge, chrome=1";

 

 

检测ie是否安装了GCF插件

function GCFInstallCheck() {
    // Look for CF in the User Agent before trying more expensive checks
    var ua = navigator.userAgent.toLowerCase();
    if (ua.indexOf("chromeframe") >= 0) {
        return true;
    }

    if (typeof window['ActiveXObject'] != 'undefined') {
        try {
            var obj = new ActiveXObject('ChromeTab.ChromeFrame');
            if (obj) {
                obj.registerBhoIfNeeded();
                return true;
            }
        } catch(e) {
            // squelch
        }
    }
    return false;
};

 

总结

  1. 如果支持Google Chrome Frame:GCF,则使用GCF渲染;
  2. 如果系统安装ie8或以上版本,则使用最高版本ie渲染;
  3. 否则,这个设定可以忽略。

你可以继续阅读相关【Google Chrome Frame , X-UA-Compatible】的文章。

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326967405&siteId=291194637