使用Navigator判斷IE的版本
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>使用Navigator判斷IE的版本Version</title>
</head>
<body>
<script>
document.write("瀏覽器代號為:"+navigator.appName);
document.write("<br />瀏覽器內(nèi)核為:"+navigator.appCodeName);
document.write("<br />瀏覽器版本為:"+navigator.appVersion);
document.write("<br />userAgent為:"+navigator.userAgent);
// 返回客戶機的瀏覽器信息
var ver=navigator.userAgent;
// 查找Trident(IE內(nèi)核)關(guān)鍵字判斷是否IE,注:IE6除外
var ieYes=ver.indexOf("Trident");
// 查找MSIE關(guān)鍵字
var vIE=ver.indexOf("MSIE");
// 獲取瀏覽器的名稱
var sAppName=navigator.appName;
// 提取關(guān)鍵字后面的3位版本號
var v=ver.substr(vIE+5,3);
var str="Internet Explorer "
// 是否IE內(nèi)核,這里指IE7-IE11
if(ieYes>-1){
// IE7---IE9的判斷
if(vIE>-1){
document.write("<br />瀏覽器為:"+str+v);
// IE10和IE11的區(qū)別是瀏覽器的名稱不同
}else if(sAppName=="Microsoft Internet Explorer"){
document.write("<br />瀏覽器為:"+str+"10.0");
// IE11為:"Netscape"
}else if(sAppName=="Netscape"){
document.write("<br />瀏覽器為:"+str+"11.0");
}
// 通過檢測MSIE關(guān)鍵字,判斷是否ie6
}else if(vIE>-1){
document.write("<br />瀏覽器為:"+str+v);
// 兩個關(guān)鍵字都沒有的肯定不是IE了
}else{
document.write("<br />不是IE瀏覽器!");
}
</script>
</body>
</html>
2018-12-09
很有意思的對象