Home >Web Front-end >JS Tutorial >JAVASCRIPT to get IE version number and HTML to set IE document mode

JAVASCRIPT to get IE version number and HTML to set IE document mode

高洛峰
高洛峰Original
2016-10-12 13:19:051049browse

JavaScript to get the IE version code:

var gIE = getIE();
           alert(gIE.version)
        function getIE() {
            var rmsie = /(msie) ([\w.]+)/;
            var ua = navigator.userAgent.toLowerCase();
            var match = rmsie.exec(ua)
            var result = {};
            if (match && match.length > 0) {
                result = { browser: match[1] || "", version: match[2] || "0" }
            }
            return result;
        }

If the IE version is compatible and an error occurs when using compatibility mode, you can use the following code:

<meta http-equiv="x-ua-compatible" content="IE=9;IE=8" />
 <meta http-equiv="x-ua-compatible" content="IE=9,8" />

Specify the browser to use a specific document mode. Content content can be written in two ways, either separated by ";" or separated by ","; regardless of the writing order, the browser will select the highest version it supports from this list to render using standard mode.

There is another way:

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

The effect that can be achieved by writing this way is that if GCF is installed, GCF will be used to render the page. If GCF is not installed, the highest version of the IE kernel will be used for rendering. Google Chrome Frame (Google Embedded Browser Framework GCF). This plug-in can keep the user's IE browser unchanged, but when browsing the web, the user is actually using the Google Chrome browser core, and supports multiple versions of IE browsers such as IE6, 7, and 8.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn