1 function checkbrowser () {2 var sys ={}; 3 var UA = navigator. useragent. tolowercase (); 4 var s; 5 var scan; 6 (S = UA. match (/MSIE ([\ D.] + )/))? SYS. Ie = s [1]: 7 (S = UA. Match (/Firefox \/([\ D.] + )/))? SYS. Firefox = s [1]: 8 (S = UA. Match (/chrome \/([\ D.] + )/))? SYS. Chrome = s [1]: 9 (S = UA. Match (/opera. ([\ D.] + )/))? SYS. Opera = s [1]: 10 (S = UA. Match (/version \/([\ D.] +). * Safari /))? SYS. safari = s [1]: 0; 11 12 // test 13 14 if (sys. IE) 15 {16 scan = "your IE kernel" + sys. IE + "Browser"; 17 $ ("# boxcontent_box "). addclass ("BG"); 18 19} 20 if (sys. firefox) 21 {22 scan = "you are using the Firefox kernel" + sys. firefox + "browser. If any problem occurs, we recommend that you use IE"; 23} 24 if (sys. chrome) 25 {26 scan = "you are using the chrome kernel" + sys. chrome + "browser. If any problem occurs, we recommend that you use IE"; 27} 28 If (sys. opera) 29 {30 scan = "you are using the opera kernel" + sys. opera + "browser. If any problem occurs, we recommend that you use IE"; 31} 32 If (sys. safari) 33 {34 scan = "you are using the safari kernel" + sys. safari + "browser. If any problem occurs, we recommend that you use IE"; 35} 36 // alert (SCAN) 37}
Browser type check