浏览器的版本问题自己先记一下,以后再补充:

 <script>
 if(navigator.userAgent.indexOf("Opera") != -1) {
 alert('Opera');
 }
 else if(navigator.userAgent.indexOf("MSIE") != -1) {
 alert('Internet Explorer');
 }
 else if(navigator.userAgent.indexOf("Firefox") != -1) {
 alert('Firefox');
 }
 else if(navigator.userAgent.indexOf("Netscape") != -1) {
 alert('Netscape');
 }
 else if(navigator.userAgent.indexOf("Safari") != -1) {
 alert('Safari');
 }
// else{
// alert('无法识别的浏览器。');
// }
 if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/6./i)=="6."){
     alert("IE 6");
 }
 else if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/7./i)=="7."){
     alert("IE 7");
 }
 else if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/8./i)=="8."){
     alert("IE 8");
 }
 else if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/9./i)=="9."){
     alert("IE 9");
 }
 </script>
posted on 2015-04-07 17:01  虽然如此  阅读(214)  评论(0编辑  收藏  举报