js判断是哪个浏览器 哪个操作系统[网络搜集]

js判断是哪个浏览器 哪个操作系统[网络收集]




<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
<HTML> 
<HEAD> 
<script> 
function checkObj() { 
   if(navigator.userAgent.indexOf("IE")>0) { 
        return "IE"; 
   } 
   if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){ 
        return "Firefox"; 
   } 
   if(isSafari=navigator.userAgent.indexOf("Safari")>0) { 
        return "Safari"; 
   } 
   if(isCamino=navigator.userAgent.indexOf("Camino")>0){ 
        return "Camino"; 
   } 
   if(isMozilla=navigator.userAgent.indexOf("Gecko")>0){ 
        return "Gecko"; 
   } 

} 
</script> 
</HEAD> 
<BODY onload="alert(check())"> 
</BODY> 
</HTML>










<script type="text/javascript">

var browser=navigator.appName

var b_version=navigator.appVersion

var version=b_version.split(";");

var trim_Version=version[1].replace(/[ ]/g,"");

if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE7.0")

{

    alert("IE 7.0");

}

    else if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE6.0")

{

    alert("IE 6.0");

}

</script>

















使用JS架框有现成的判断 
例如motools架框中:
Browser.Platform.mac - (boolean) 当前操作系统是否为Mac
Browser.Platform.win - (boolean) 当前操作系统是否为Windows
Browser.Platform.linux - (boolean) 当前操作系统是否为Linux
Browser.Platform.ipod - (boolean) 当前操作系统是否为iPod Touch / iPhone
Browser.Platform.other - (boolean) 当前操作系统即不是Mac, 也不是Windows或Linux
Browser.Platform.name - (string) 当前操作系统的名称