-James Padolsey判断法
1 <head>
2 <script type="text/javascript">
3 var ie = (function(){
4 var undef,
5 v = 3,
6 div = document.createElement('div'),
7 all = div.getElementsByTagName('i'); while (
8 div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->',
9 all[0]
10 ) ;
11 return v > 4 ? v : undef }());
12 function is_ie(){
13 if(!ie)
14 alert("您当前使用非Microsoft Internet Explorer.");
15 else if (ie<=6)
16 alert("您当前使用的浏览器版本过低。为获取良好的用户体验,\n请选择 IE 7.0 及其以上版本的Microsoft Internet Explorer.");
17
18 }//一楼 Jefft 评论说漏了一半大括号,现在补充了,多谢了。
19
20 </script> </head> <body onload="is_ie()"> </body>
2 <script type="text/javascript">
3 var ie = (function(){
4 var undef,
5 v = 3,
6 div = document.createElement('div'),
7 all = div.getElementsByTagName('i'); while (
8 div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->',
9 all[0]
10 ) ;
11 return v > 4 ? v : undef }());
12 function is_ie(){
13 if(!ie)
14 alert("您当前使用非Microsoft Internet Explorer.");
15 else if (ie<=6)
16 alert("您当前使用的浏览器版本过低。为获取良好的用户体验,\n请选择 IE 7.0 及其以上版本的Microsoft Internet Explorer.");
17
18 }//一楼 Jefft 评论说漏了一半大括号,现在补充了,多谢了。
19
20 </script> </head> <body onload="is_ie()"> </body>
---jquery判断法<script src="../Scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
function OpenLoad() {
if (document.getElementById) {
var bro = $.browser;
if (bro.msie) {
binfo = "Microsoft Internet Explorer " + bro.version;
}
else if (bro.mozilla) {
binfo = "Mozilla Firefox " + bro.version;
}
else if (bro.safari) {
binfo = "Apple Safari " + bro.version;
}
else if (bro.opera) {
binfo = "Opera " + bro.version;
}
alert(binfo);
}
}
</script>
<body onload="OpenLoad();">
</body>