I made a business to judge the browser type and version number, and recorded the relevant js code. I personally feel pretty good, you can refer to the following two days to make a business that judges the browser type and version number, and record the relevant js Code:
The Code is 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 obtain the browser version: match [2]
Switch (match [1]) {
Case "msie": // ie
If (parseInt (match [2]) === 6) {// ie6
Alert ("ie6 ");
Alert ("IE7.0 and earlier browsers are not supported currently. 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;
}
}