JS判断浏览器类型
时间:2008-12-04 来源:hkebao
研究一下为什么会出现这种问题吧?
1.JS判断浏览器类型
function detectBrower()
...{
var sUserAgent = navigator.userAgent;
var isOpera = sUserAgent.indexOf("Opera") > -1;
if(isOpera) return "Opera";
var isKHTML = sUserAgent.indexOf("KHTML") > -1 || sUserAgent.indexOf("Konqueror") > -1 || sUserAgent.indexOf("AppleWebKit") > -1;
var isSafari = sUserAgent.indexOf("AppleWebKit") > -1 && isKHTML;
var isKonq = sUserAgent.indexOf("Konqueror") > -1 && isKHTML;
if(isSafari) return "Safari";
if(isKonq) return "Konqueror";
var isIE = sUserAgent.indexOf("compatible") > -1 && sUserAgent.indexOf("MSIE") > -1 && !isOpera;
if(isIE) return "IE";
var isMoz = sUserAgent.indexOf("Gecko") > -1 && !isKHTML;
if(isMoz) return "Mozilla";
return "None";
}
这样子是可以判断出来这个东东的哦!
function getNavi()
{
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("您的浏览器类型为:"+getNavi());
可以判断出来浏览器的类型的哦!
[下面也是可以判断浏览器的类型的哦]
[]
1.JS判断浏览器类型
function detectBrower()















这样子是可以判断出来这个东东的哦!
function getNavi()
{
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("您的浏览器类型为:"+getNavi());
可以判断出来浏览器的类型的哦!
[下面也是可以判断浏览器的类型的哦]
[]
相关阅读 更多 +