Home  >  Article  >  Web Front-end  >  A collection of js judgment methods for ie (including regular expressions) short and classic codes [original]_javascript skills

A collection of js judgment methods for ie (including regular expressions) short and classic codes [original]_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:02:21856browse

Whether it is Opera:


[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute
]

Whether it is IE:

[Ctrl A Select all Note:
If you need to introduce external Js, you need to refresh to execute
]
Whether it is ie7: Copy code
The code is as follows:


<script> <br>(is_ie && /msie 7.0/ i.test(navigator.userAgent)); </div></script>
[Ctrl A Select all Note:
If you need to introduce external Js, you need to refresh to execute
]

[Ctrl A Select all Note:
If you need to introduce external Js, you need to refresh to execute
]
javascript judgment ie Version
<script> is_opera = /opera/i.test(navigator.userAgent); alert(is_opera); </script>[Ctrl A select all Note: <script> is_opera = /opera/i.test(navigator.userAgent); var is_ie = (/msie/i.test(navigator.userAgent) && !is_opera) alert(is_ie); </script>If you need to introduce external Js, you need to refresh to execute <script> var isIe = /msie/i.test(navigator.userAgent); alert(isIe); </script>]<script> if(document.uniqueID){ alert("脚本在IE浏览器中运行!"); }else{ alert("脚本在非IE浏览器中运行!"); } </script> <script> function Browser() { var ua, s, i; this.isIE = false; // Internet Explorer this.isNS = false; // Netscape this.version = null; ua = navigator.userAgent; s = "MSIE"; if ((i = ua.indexOf(s)) >= 0) { this.isIE = true; this.version = parseFloat(ua.substr(i + s.length)); return; } s = "Netscape6/"; if ((i = ua.indexOf(s)) >= 0) { this.isNS = true; this.version = parseFloat(ua.substr(i + s.length)); return; } // Treat any other "Gecko" browser as NS 6.1. s = "Gecko"; if ((i = ua.indexOf(s)) >= 0) { this.isNS = true; this.version = 6.1; return; } } var browser = new Browser(); alert(browser); </script>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn