Detect IE browser by using JavaScript

來源:互聯網
上載者:User

標籤:span   root   ide   use   navigator   string   oca   log   on()   

 1 <script> 2 function detectIE() { 3     var ua = window.navigator.userAgent; 4  5     var msie = ua.indexOf(‘MSIE ‘); 6     if (msie > 0) { 7         // IE 10 or older => return version number 8 //                return parseInt(ua.substring(msie + 5, ua.indexOf(‘.‘, msie)), 10); 9         return true;10     }11 12     var trident = ua.indexOf(‘Trident/‘);13     if (trident > 0) {14         // IE 11 => return version number15 //                var rv = ua.indexOf(‘rv:‘);16 //                return parseInt(ua.substring(rv + 3, ua.indexOf(‘.‘, rv)), 10);17         return true;18     }19 20     var edge = ua.indexOf(‘Edge/‘);21     if (edge > 0) {22         // Edge (IE 12+) => return version number23 //                return parseInt(ua.substring(edge + 5, ua.indexOf(‘.‘, edge)), 10);24         return true;25     }26 27     // other browser28     return false;29 }30 31 function alert_browser_version() {32     if(detectIE()){33         alert("Browser Error:\nWe are strongly recommend you visit the website via Chrome or Firefox instead of IE.");34         window.location.href = "http://hkw20016704.hbap.adroot.hsbc:8000/cr/index/";35         return false;36     }37 }38 </script>

 

<body onload="alert_browser_version()">....</body>

  

Detect IE browser by using JavaScript

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.