• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

5. Browser Feature Detection > 5.3. Detecting the Internet Explorer Version

Detecting the Internet Explorer Version

NN n/a, IE 3

Problem

You want script execution to branch based on a specific or minimum version of Internet Explorer.

Solution

Access the complete version number by parsing the string of the navigator.userAgent property. Internet Explorer identifies itself with the string MSIE , followed by a space, the version number (with one or more digits to the right of the decimal), and a semicolon. Here’s a function that returns the numeric portion of the pertinent information:

function getIEVersionNumber( ) {
    var ua = navigator.userAgent;
    var MSIEOffset = ua.indexOf("MSIE ");
    if (MSIEOffset =  = -1) {
        return 0;
    } else {
        return parseFloat(ua.substring(MSIEOffset + 5, ua.indexOf(";", MSIEOffset)));
    }
}

PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint