js中区分浏览器类型(navigator的userAgent属性)

通过navigator属性检查浏览器是什么浏览器

var cu = navigator.userAgent;

if('ActiveXObject' in window){

    alert('是ie浏览器')

}else if(/firefox/i.test(cu)){

   alert('是火狐浏览器')

}else if(/chrome/i.test(cu)){

   alert('是谷歌浏览器')

}

猜你喜欢

转载自blog.csdn.net/qq_35872777/article/details/85272300