一、判斷IE FF瀏覽器方法(測(cè)試過(guò)沒(méi)問(wèn)題)
var Browser1={
ie:/msie/.test{window.navigator.userAgent.toLowerCase()),
ff:/firefox/.test(window.navigator.userAgent.toLowerCase())
}
二、判斷ie opera firefox safari(測(cè)試過(guò),應(yīng)該沒(méi)問(wèn)題)
var Browser2={};
var ua=navigator.userAgent.toLowerCase();
if(window.ActiveXObject){
Browser2.ie=ua.match(/msie([\d.]+)/)[1]; }else if(document.getBoxObjectFor){
Browser2.firefox=ua.match(/firefox\/([\d.]+)/)[1];
}else if(window.opera){
Browser2.opera=ua.match(/opera.([\d.]+)/)[1];
}else if(window.openDatabase){
Browser2.safari=ua.match(/version\/([\d.]+)/)[1];
}
三、判斷ie chrome firefox safari(測(cè)試過(guò),沒(méi)問(wèn)題)
if(navigator.userAgent.indexOf("MSIE")>0){
//ie
}else if(navigator.userAgent.indexOf("Firefox")>0){
//firefox
}else if(navigator.userAgent.indexOf("Chrome")>0){
//chrome
}else if(navigator.userAgent.indexOf("Safari")>0){
//safari
}else{
//this part can be used as opera area
}
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶(hù)發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)
點(diǎn)擊舉報(bào)。