浏览器判断

来源:互联网 发布:淘宝代购是什么意思 编辑:程序博客网 时间:2024/05/21 03:26
<!--[if !IE]><!--> 除IE外都可识别 <!--<![endif]-->
<!--[if IE]> 所有的IE可识别 <![endif]-->
<!--[if IE 6]> 仅IE6可识别 <![endif]-->
<!--[if lt IE 6]> IE6以及IE6以下版本可识别 <![endif]-->
<!--[if gte IE 6]> IE6以及IE6以上版本可识别 <![endif]-->
<!--[if IE 7]> 仅IE7可识别 <![endif]-->
<!--[if lt IE 7]> IE7以及IE7以下版本可识别 <![endif]-->
<!--[if gte IE 7]> IE7以及IE7以上版本可识别 <![endif]-->
<!--[if IE 8]> 仅IE8可识别 <![endif]-->

<!--[if IE 9]> 仅IE9可识别 <![endif]-->


if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/6./i)=="6."){ 
alert("IE 6"); 

if(navigator.appName=="Microsoft Internet Explorer"&& navigator.appVersion.Math(/6./i)=="6."){
}
else if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/7./i)=="7."){ 
alert("IE 7"); 

else if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/8./i)=="8."){ 
alert("IE 8"); 

else if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/9./i)=="9."){ 
alert("IE 9"); 
}else if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/10./i)=="10."){ 
alert("IE 10"); 
} else if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/11./i)=="11."){ 
alert("IE 11"); 
}  if(navigator.userAgent.indexOf("Opera") != -1) { 
alert('Opera'); 

else if(navigator.userAgent.indexOf("MSIE") != -1) { 
alert('Internet Explorer'); 

else if(navigator.userAgent.indexOf("Firefox") != -1) { 
alert('Firefox'); 

else if(navigator.userAgent.indexOf("Netscape") != -1) { 
alert('Netscape'); 

else if(navigator.userAgent.indexOf("Safari") != -1) { 
alert('Safari'); 

else{ 
alert('无法识别的浏览器。'); 

0 0
原创粉丝点击