JS code to determine the different versions of IE

Source: Internet
Author: User

Method One:

<script type= "Text/javascript" > var browser=navigator.appname var b_version=navigator.appversion var version=b_ Version.split (";"); var trim_version=version[1].replace (/[]/g, ""); if (browser== "Microsoft Internet Explorer" && trim_version== "MSIE6.0") {alert ("IE 6.0");} else if (browser== " Microsoft Internet Explorer && trim_version== "MSIE7.0") {alert ("IE 7.0"); window.location.href= "http:// Xxxx.com ";} else if (browser== "Microsoft Internet Explorer" && trim_version== "MSIE8.0") {alert ("IE 8.0");} else if (browser== "Microsoft Internet Explorer" && trim_version== "MSIE9.0") {alert ("IE 9.0");} </script>

Method Two:

<script type= "Text/javascript" >if(Navigator.appname = = "Microsoft Internet Explorer" && navigator.appversion split (";") [1].replace (/[]/g, "") = = "MSIE6.0") {alert ("IE 6.0"); } Else if(Navigator.appname = = "Microsoft Internet Explorer" && navigator.appversion split (";") [1].replace (/[]/g, "") = = "MSIE7.0") {alert ("IE 7.0"); } Else if(Navigator.appname = = "Microsoft Internet Explorer" && navigator.appversion split (";") [1].replace (/[]/g, "") = = "MSIE8.0") {alert ("IE 8.0"); } Else if(Navigator.appname = = "Microsoft Internet Explorer" && navigator.appversion split (";") [1].replace (/[]/g, "") = = "MSIE9.0") {alert ("IE 9.0"); } </script>

Method Three:

<script type= "Text/javascript" > if (navigator.appname = = "Microsoft Internet Explorer" && Navigator.appVersion.match (/7./i) = = "7.") {Alert ("IE 7.0");} else if (navigator.appname = = "Microsoft Internet Explorer" && navigator.appVersion.match (/8./i) = = "8.") {Alert ("IE 8.0");} else if (navigator.appname = = "Microsoft Internet Explorer" && navigator.appVersion.match (/9./i) = = "9.") {Alert ("IE 9.0");} else if (navigator.appname = = "Microsoft Internet Explorer") {alert ("IE 6.0");} </script>

  

JS code to determine the different versions of IE

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.