I test the code from the microsoft company site, but it defines my IE as the seventh version, although I have the eighth version (written in the About clause). What's wrong?

function getInternetExplorerVersion() { var rv = -1; if (navigator.appName == 'Microsoft Internet Explorer') { var ua = navigator.userAgent; var re = new RegExp('MSIE ([0-9]{1,}[\.0-9]{0,})'); if (re.exec(ua) != null) rv = parseFloat(RegExp.$1); } return rv; } 

enter image description here

This code is for IE only.

IE version 6 is detectable.

What is the reason?

the contents of the variable ua:

enter image description here

  • 2
    Check in what mode the page is open. It is quite possible it is open in compatibility mode with IE7 - Grundy
  • @Grundy did not help, acted according to this instruction help.inbox.lv/question/525/31?language=ru - perfect
  • @perfect UserAgent in the studio. And I also advise you to look at document.documentMode - Sublihim
  • @Sublihim added to the question, document.documentMode = 5 - perfect
  • @perfect, well, that's: compatible; MSIE 7.0 compatible; MSIE 7.0 Open the console and see what really is your compatibility mode. And add to the question the full HTML code that you check. Rather, you can only DOCTYPE - Grundy

1 answer 1

According to the results of the comments, I will issue an answer. In this case, it seems to me the algorithm should be like this:

  1. Define document.documentMode ,
  2. If documentMode ===5 , (hence IE is in quirks mode ). to execute p.3 otherwise p.4

  3. Determine the version of Trident and then calculate the version of IE

  4. Determine the version of IE proposed in the answer method