Web page effects browser type and version information detection code
function Check (reg) {
var ug = navigator.userAgent.toLowerCase ();
Return Reg.test (UG);
}
function Checkbrowser () {
var ug = navigator.userAgent.toLowerCase ();
var useragent = document.getElementById ("useragent");
useragent.innerhtml = "browser's user Agent header:" + ug;
var browsertype = "";
var ver = "";
Detect IE and version
var ie = Ug.match (/msies*d.d/); Extracts browser type and version information, note that the match () method returns an array rather than a string
var Isie = check (/msie/);
if (Isie) {
BrowserType = "Internet Explorer";
ver = Ie.join (""). Match (/[0-9]/g). Join ("."); Use the Join () method to convert to a string, then match the match () method to the version information, and then use the join () method to convert to a string
}
Detecting Chrome and version
var chrome = Ug.match (/CHROME/D.D/GI);
var ischrome = check (/chrome/);
if (ischrome) {
BrowserType = "Chrome";
ver = Chrome.join (""). Match (/[0-9]/g). Join (".");
}
Detect Firefox and version
var Firefox = ug.match (/firefox/d.d/gi);
var isfirefox = check (/firefox/);
if (Isfirefox) {
BrowserType = "Firefox";
ver = Firefox.join (""). Match (/[0-9]/g). Join (".");
}
var browser = document.getElementById ("browser");
browser.innerhtml = "The browser you are using is:" + BrowserType + "<span style= ' padding-left:15px;" > Version for:</span> "+ ver;
}