These two days to make a judgment of the browser type and version number of the business, record the relevant JS code:
Copy Code code as follows:
function Allinfo () {
var ua = navigator.useragent;
UA = Ua.tolowercase ();
var match =/(WebKit) [\/] ([\w.] +)/.exec (UA) | |
/(opera) (?:. *version)? [ \/] ([\w.] +)/.exec (UA) | |
/(MSIE) ([\w.] +)/.exec (UA) | |
!/compatible/.test (UA) &&/(Mozilla) (?:. *? RV: ([\w.] +))?/.exec (UA) | | [];
If you need to get the browser version number: match[2]
Switch (match[1]) {
Case "MSIE"://ie
if (parseint (match[2]) = = 6) {//ie6
Alert ("IE6");
Alert ("Temporarily does not support IE7.0 and the following version of browsers, please upgrade your browser version!") ");
document.getElementById ("hid"). Style.display = "None";
document.getElementById ("Show"). Style.display = "block";
document.getElementById ("Nosee_b"). Style.display = "None";
}
else if (parseint (match[2]) = = 7) {//ie7
Alert ("IE7");
document.getElementById ("hid"). Style.display = "None";
document.getElementById ("Show"). Style.display = "block";
}
else if (parseint (match[2]) = = 8) {//IE8
Alert ("IE8");
}
else if (parseint (match[2]) = = 9) {
Alert ("IE9");
document.getElementById ("hid"). Style.display = "None";
}
Break
Case "WebKit"://safari or Chrome
Alert ("Safari or Chrome");
document.getElementById ("Middle"). Style.display = "None";
Break
Case "Opera"://opera
Alert ("opera");
Break
Case "Mozilla"://firefox
Alert ("Firefox");
document.getElementById ("hid"). Style.display = "None";
Break
Default
Break
}
}