1 <script type="text/javascript">
2 if (navigator.appName.indexOf("Microsoft Internet Explorer") != -1) {
3 alert("我是ie");
4 if (navigator.userAgent.indexOf("MSIE 6.0") > 0)//IE 6.0
5 {
6 alert("我是ie6");
7 }
8 else if (navigator.userAgent.indexOf("MSIE 7.0") > 0)//IE 7.0
9 {
10 alert("我是ie7");
11 }
12 else if (navigator.userAgent.indexOf("MSIE 8.0") > 0)//IE 8.0
13 {
14 alert("我是ie8");
15 }
16 }
17 else if (navigator.userAgent.indexOf("Netscape") != -1)//我是Netscape
18 {
19 alert("Netscape");
20 }
21 else if (navigator.appName.indexOf("Opera") != -1) //我是opera
22 {
23 alert("Opera");
24 }
25 else if (navigator.userAgent.indexOf("Firefox") != -1)//我是Firefox
26 {
27 alert("Firefox");
28 }
29 else if (navigator.userAgent.indexOf("Chrome") != -1)//我是chrom
30 {
31 alert("Chrome");
32 }
33 else if (navigator.userAgent.indexOf("Safari") != -1)//我是chrom
34 {
35 alert("Safari");
36 }
37 </script>