0) is the ie browser. navigator.appName.indexOf("Microsoft") != -1 for IE browser. navigator.userAgent.indexOf("MSIE 6.0")>0 determines whether it is ie6 navigator.appVersion.match(/6./i)=="6.&quo"/> 0) is the ie browser. navigator.appName.indexOf("Microsoft") != -1 for IE browser. navigator.userAgent.indexOf("MSIE 6.0")>0 determines whether it is ie6 navigator.appVersion.match(/6./i)=="6.&quo">

Home >Web Front-end >JS Tutorial >Use JS to determine the current browser type

Use JS to determine the current browser type

怪我咯
怪我咯Original
2017-06-27 11:43:591397browse

if(navigator.userAgent.indexOf("MSIE")>0) for IE browser.


navigator.appName.indexOf("Microsoft") != -1 for IE browser.


navigator.userAgent.indexOf("MSIE 6.0")>0 Determine whether it is ie6


navigator. appVersion.match(/6./i)=="6." Determine whether it is ie6


js Get browser information

Browser code name : navigator.appCodeName

Browser name: navigator.appName

Browser version number: navigator.appVersion

Support for Java: navigator.javaEnabled()

MIME types (array): navigator.mimeTypes

System platform: navigator.platform

Plug-ins (array): navigator.plugins

User agent: navigator.userAgent

DEMO:

Js code

<script language="JavaScript">  
    <!--  
function getOs()  
{  
    var OsObject = "";  
   if(navigator.userAgent.indexOf("MSIE")>0) {  
        return "MSIE";  
   }  
   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";  
   }  
    
}  
 alert("您的浏览器类型为:"+getOs());  
    -->  
</script>


The above is the detailed content of Use JS to determine the current browser type. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn