In front-end development often encounter a series of compatibility issues, how to accurately identify the version of each browser is a headache, especially navigator may be forged by the manufacturer. While the great gods recommend that you work with browser features rather than through browser versions, there are considerable difficulties in the actual operation.
Here are the various browser sniffing methods that the great gods have summed up.
IE article:
ie=!! Window. VBArray
ie678=!+ "\v1"; ie678=!-[1,];ie678= ' \v ' = = ' V '; ie678= (' A-B '. Split (/(~)/)) [1]==]ie678=0.9.tofixed (0) = = "0"ie678=/\w/.test (' \u0130 ') IE8=WINDOW.TOSTATICHTMLIE9=window.msperformanceie678=0//@cc_on +1;ie67=! " 1 "[0] IE8=!!window. XDOMAINREQUEST;IE9=document.documentmode&&document.documentmode===9; Ie10=Window.navigator.mspointerenabled;ie11= !! Window. Msinputmethodcontext;
Firefox article:
Firefox=!!window.netscape;
firefox=!! Window.updatecommands;
safari=window.opendatabase&&!window.chrome;
chrome=!! (Window.chrome&&window.google);
Mobile device article:
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
The most powerful browser sniffer in history