如何判断是什么浏览器

chrome


var isChrome = window.navigator.userAgent.indexOf("Chrome") !== -1;

Fire Fox


var isFirefox=navigator.userAgent.toUpperCase().indexOf("FIREFOX")?true:false;

IE


var isIE=navigator.userAgent.toUpperCase().indexOf("MSIE")?true:false;

IE9 嗅探

ie=!!window.VBArray
ie678=!+"\v1";
ie678=!-[1,];
ie678='\v'=='v';
ie678=('a-b'.split(/(~)/))[1]=="b"
ie678=0.9.toFixed(0)=="0"
ie678=/\w/.test('\u0130') 
ie8=window.toStaticHTML
ie9=window.msPerformance
ie678=0//@cc_on+1;
ie67=!"1"[0] 
ie8=!!window.XDomainRequest;
ie9=document.documentMode&&document.documentMode===9;
ie10 = window.navigator.msPointerEnabled;
ie11 = !!window.MSInputMethodContext;

其他浏览器嗅探


firefox=!!window.netscape;
firefox=!!window.updateCommands;
safari=window.openDatabase&&!window.chrome;
chrome=!!(window.chrome&&window.google);

移动端


iphone=/iphone/i.test(navigator.userAgent);
iphone4=window.devicePixelRatio>=2;
ipad=/iPad/i.test(navigator.userAgent);
[Android]=/android/i.test(navigator.userAgent);
[iOS]=iphone||ipad;

你可能感兴趣的:(如何判断是什么浏览器)