用js判斷當前是什麼瀏覽器
阿新 • • 發佈:2019-01-28
判斷當前瀏覽器型別程式碼
<script type="text/javascript" >
<!--
function getOs()
{
var OsObject = "";
if(isIE = navigator.userAgent.indexOf("MSIE")!=-1) {
return "MSIE";
}
if(isFirefox=navigator.userAgent.indexOf("Firefox")!=-1){
return "Firefox";
}
if(isChrome=navigator.userAgent.indexOf("Chrome")!=-1){
return "Chrome";
}
if(isSafari=navigator.userAgent.indexOf("Safari")!=-1) {
return "Safari";
}
if(isOpera=navigator.userAgent.indexOf("Opera")!=-1){
return "Opera";
}
}
alert("type -> "+getOs());
-->
</script>