Home > Web Front-end > JS Tutorial > body text

Use JS to determine the current browser type

怪我咯
Release: 2017-06-27 11:43:59
Original
1373 people have browsed it

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>
Copy after login


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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template