1. 程式人生 > >判斷IE瀏覽器版本

判斷IE瀏覽器版本

dex agent int app ide ros useragent function soft

function IEVer(){
var rv = -1;
if (navigator.appName == ‘Microsoft Internet Explorer‘){
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null){
rv = parseFloat( RegExp.$1 );
}
}else if (navigator.appName == ‘Netscape‘){
var ua = navigator.userAgent;
var re = new RegExp("Trident/.*rv:([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null){
rv = parseFloat( RegExp.$1 );
}
}
return rv;
}
var IEVer = IEVer();

// 若是11 則返回11 ,若是其他版本則返回-1

// edge判斷

var userAgent = navigator.userAgent;
var isEdge = userAgent.indexOf("Edge")>-1;

判斷IE瀏覽器版本