[JavaScript]代码
function CheckBrowser() { ua = navigator.userAgent; ua = ua.toLocaleLowerCase(); var browserVersion; if (ua.match(/msie/) != null || ua.match(/trident/) != null) { browserType = "IE"; //哈哈,现在可以检测ie11.0了! browserVersion = ua.match(/msie ([/d.]+)/) != null ? ua.match(/msie ([/d.]+)/)[1] : ua.match(/rv:([/d.]+)/)[1]; } else if (ua.match(/firefox/) != null) { browserType = "火狐"; } else if (ua.match(/opera/) != null) { browserType = "欧朋"; } else if (ua.match(/chrome/) != null) { browserType = "谷歌"; } else if (ua.match(/safari/) != null) { browserType = "Safari"; } var arr = new Array(browserType, browserVersion); return arr; }
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/8756.html