ie浏览器判断

判断ie浏览器代码

function ie(){
    var agent = navigator.userAgent.toLowerCase();
    return (!!window.ActiveXObject || "ActiveXObject" in window) ?  (
            (agent.match(/msie\s(\d+)/) || [])[1] || '11'
        ) : false;
}
var version = ie();
alert(version)

另一种检测办法

        var versions = {

            objectobject: 7, //IE7-8

            objectundefined: 6, //IE6

            undefinedfunction: NaN, // other modern browsers

            undefinedobject: NaN //Mobile Safari 8.0.0 (iOS 8.4.0) 

        }

        /* istanbul ignore next */

        var msie = document$1.documentMode || versions[typeof document$1.all + typeof XMLHttpRequest]

        var modern = /NaN/.test(msie) || msie > 8

你可能感兴趣的:(ie浏览器判断)