jQuery检测浏览器版本

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 <head>
 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 5 <title>jQuery测试</title>
 6 <style type="text/css">
 7     
 8 </style>
 9 <script type="text/javascript" src="jquery-1.7.2.min.js"></script>
10 <script type="text/javascript">
11     $(function(){
12             
13         $('#btnTrans').css('display','none').bind('click',function(){window.self.location.replace('messagebox.html');});   
14             
15         var isSupportHtml5 = false;
16             
17         if($.browser.msie)
18         {
19             var ver = $.browser.version;
20             if(parseInt(ver) >= 9)
21             {
22                 isSupportHtml5 = true;
23             }
24             else
25             {
26                 isSupportHtml5 = false;
27             }
28         }
29         else
30         {
31             isSupportHtml5 = true;
32         }
33         
34         if(isSupportHtml5)
35         {
36             $('#msg').text("恭喜,您的浏览器支持HTML5,是否跳转到HTML页面浏览");
37             $('#btnTrans').css('display','');
38         }
39         else
40         {
41             $('#msg').text("对不起,您的浏览器不支持HTML5");
42             $('#btnTrans').css('display','none');
43         }
44     });
45 </script>
46 
47 </head>
48 
49 <body>
50 <div>
51     <span id="msg"></span><input id="btnTrans" type="button" value="点此,跳转" />
52 </div>
53 </body>
54 </html>
posted @ 2012-07-13 18:22  常伟华  阅读(202)  评论(0编辑  收藏  举报