----------------------------------------------------------------------
js判断浏览器类型
下面为大家介绍一下如何用js判断浏览器类型,以便根据不同浏览器做出不同处理,解决浏览器js兼容问题
function getExplorerType() {
var explorer = window.navigator.userAgent ; //ie 浏览器
if (explorer.indexOf("MSIE") >= 0) {
alert("ie");
}
//firefox 火狐浏览器
else if (explorer.indexOf("Firefox") >= 0) {
alert("Firefox");
}
//Chrome 谷歌浏览器
else if(explorer.indexOf("Chrome") >= 0){
alert("Chrome");
}
//Opera 浏览器
else if(explorer.indexOf("Opera") >= 0)
{ alert("Opera");
}
//Safari else if(explorer.indexOf("Safari") >= 0){
alert("Safari");
}
}