Before too lazy to write judgment ie version js, because the online about this aspect of the code too much, so from the online copy of a, put on the project only to find due to the issue of timeliness, the code does not take effect. Just write one yourself.
- How to see the browser's kernel and other information----JS Global Object Window Sub-property navigator.useragent, this property contains information about the browser information, including the browser kernel we need
- Navigator.useragent This value is a string that can be validated by the string's IndexOf method or regular match to validate the key string
- Ie11 and Edge are judged differently, and I'll give you a few figures later
- This is Ie11 's useragent.
- This is edge useragent.
- IE9 's useragent
- IE8 's useragent
- Ie10 's useragent
You must have found that the ie11 and edge of the useragent is very big difference with ie8,9,10, then the use of the writing JS need to judge, the following gives me to write a section of the judgment is IE and give the IE version number of JS code snippet
function ieversion () {var useragent = navigator.useragent;//Get the useragent string of the browser var Isie = Useragent.indexof ("compatible") >-1 && useragent.indexof ("MSIE") >-1; Determine if ie<11 browser var Isedge = useragent.indexof ("Edge") >-1 &&!isie; Determine if IE's Edge browser var isIE11 = useragent.indexof (' Trident ') >-1 && useragent.indexof ("rv:11.0") &G T -1; if (Isie) {var reie = new RegExp ("MSIE (\\d+\\.\\d+);"); Reie.test (useragent); var fieversion = parsefloat (regexp["$"]); if (fieversion = = 7) {return 7; } else if (fieversion = = 8) {return 8; } else if (fieversion = = 9) {return 9; } else if (fieversion = =) {return 10; } else {return 6;//ie version <=7}} elSe if (isedge) {return ' Edge ';//edge} else if (isIE11) {return one;//ie11 }else{return-1;//not IE browser}}
The return value can be obtained by calling Ieversion (), with the following values
Value |
Value type |
Value Description |
-1 |
Number |
Not IE browser |
6 |
Number |
IE version <=6 |
7 |
Number |
Ie7 |
8 |
Number |
Ie8 |
9 |
Number |
Ie9 |
10 |
Number |
Ie10 |
11 |
Number |
Ie11 |
' Edge ' |
String |
IE's Edge browser |
JS to determine whether it is IE browser and give the IE version