我想检测用户是否使用IE和Firefox,但我找不到脚本.
我的代码如下:
$(document).ready(function(e) {
$.browser.chrome = /chrom(e|ium)/.test(navigator.userAgent.toLowerCase());
if($.browser.chrome){
alert(1);
//this work well
}
else if(//the browser is IE){alert(2);}
else if(//the browser is Firefox){alert(3);}
//The problem is that I don't know how to write a script for IE and FireFox browser for chrome is work fine
)};
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用此行来检测浏览器类型:IE或Firefox.
alert(isBrowser("Microsoft"));
Run Code Online (Sandbox Code Playgroud)
但我绝对没有,警报甚至没有弹出.不知道我做错了什么.
检测浏览器类型的最佳实践方法是什么?