瀏覽器版本控制

瀏覽器的版本問題本身先記一下,之後再補充:javascript

<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>
相關文章
相關標籤/搜索