Programatically detect IE6 or IE7 ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tcurrier
    New Member
    • Jan 2007
    • 4

    Programatically detect IE6 or IE7 ?

    Hello,

    Is there a way in Javascript to tell if a user has IE7 vs. IE6 ?

    Thanks for any help....
  • AricC
    Recognized Expert Top Contributor
    • Oct 2006
    • 1885

    #2
    This page should help you out.

    Comment

    • tcurrier
      New Member
      • Jan 2007
      • 4

      #3
      Thanks.... I tried the code suggested, but it tells me that I have version 4 of MSIE when I actually have version 7.

      Any ideas ?

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        On that page, it has the following:
        Originally posted by W3Schools
        IMPORTANT! The version number is WRONG in IE 5.0 or later! Microsoft starts the appVersion string with the number 4.0. in IE 5.0 and IE 6.0!!! Why did they do that??? However, JavaScript is the same in IE6, IE5 and IE4, so for most scripts it is ok.

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Instead of using appVersion, use navigator.userA gent instead then use a regular expression to parse it to find the version number as explained from the horse's mouth.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            You can also use conditional compilation. The j_script_versio n for IE7 is 5.7

            Yet another option is conditional comments:
            <!–[if IE 7]>
            // ie7 code
            <![endif]–>
            See here .

            Comment

            Working...