The object used to reflect the browser and its functional information.
// Detect browser version information function getBrowserInfo(){ var Sys = {}; var ua = window.navigator.userAgent.toLowerCase(); var re =/(msie|firefox|chrome|opera|version).*?([/d.]+)/; var m = ua.match(re); Sys.browser = m[1].replace(/version/, "'safari"); Sys.ver = m[2]; return Sys;}var BomInfo = getBrowserInfo;console.log(BomInfo ());How to judge whether it is ie?
var navigatorName = "Microsoft Internet Explorer"; var isIE = false; if( window.navigator.appName == navigatorName ){ isIE = true; alert("ie") }else{ alert("not ie") }There is another method:
if(window.addEventListener){ alert("not ie"); }else if(window.attachEvent){ alert("is ie"); }else{ alert("This happens in old browsers that do not support DHTML (it is generally supported now)") }Determine the device type:
function browserType() { var sUserAgent = navigator.userAgent.toLowerCase(); //The browser's user agent is set to lowercase, and then match var isIpad = sUserAgent.match(/ipad/i) == "ipad"; //Or use indexOf method to match var isIphoneOs = sUserAgent.match(/iphone os/i) == "iphone"; var isMidp = sUserAgent.match(/midp/i) == "midp"; //Mobile information device description MIDP is a set of Java application programming interfaces, mostly suitable for Symbian systems var isUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4"; //CVS tag var isUc = sUserAgent.match(/ucweb/i) == "ucweb"; var isAndroid = sUserAgent.match(/android/i) == "android"; var isCe = sUserAgent.match(/windows ce/i) == "windows ce"; var isWM = sUserAgent.match(/windows mobil/i) == "windows mobil"; if (isIpad || isIphoneOs || isMidp || isUc7 || isUc || isAndroid || isCe || isWM) { alert('This device is a mobile device'); // Do something} else { alert('This device is a PC device'); // Do something}}browerType();The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.