1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>判断浏览器类型及版本</title> 6 <meta name="Keywords" content=""> 7 <meta name="author" content="@my_programmer"> 8 <script src="http://code.jquery.com/jquery-1.7.2.min.js" type="text/javascript"></script> 9 </head> 10 <body> 11 <script type="text/javascript"> 12 var chars=navigator.userAgent; //浏览器的用户代理字符串 13 var bro=$.browser; 14 if(chars.indexOf("Chrome")>0){ 15 alert("Chrome"+bro.version); 16 } 17 if(chars.indexOf("IE")>0){ 18 alert("IE"+bro.version); 19 } 20 if(chars.indexOf("Safari")>0&&chars.indexOf("Chrome")<0){ 21 alert("Safari"+bro.version); 22 } 23 if(chars.indexOf("Opera")>0){ 24 alert("Opera"+bro.version); 25 } 26 if(chars.indexOf("Firefox")>0){ 27 alert("Firefox"+bro.version); 28 } 29 </script> 30 </body> 31 </html>