SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    ...
    Join Date
    Jan 2002
    Location
    London, UK
    Posts
    759
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JS detect IE4 without catching IE5.0

    Has anyone tried working out this one?

    How to detect IE4 without wrongly detecting IE5.0 (IE5.0 usually returns a navigator.appVersion of 4.0)

    Here's the code im working with using substring of IE version:

    Code:
    // <head>
    <script language="JavaScript">
     this.version = navigator.appVersion;  
    </script>
    Code:
    // <body>
    <script language="JavaScript">
    
    if (navigator.appName == "Microsoft Internet Explorer"){
        if (version.substring(0,1) <= 4){
    	if (version.substring(22,23) <= 4){
    	document.write("This Browser is IE4 or lower!");
     }
            else{
    	document.write("This Browser is IE5 or higher!");
      }
     }
    }
    else{
    document.write("This Browser isn't IE!");
    }
    
    document.write("<br>This Browser is " +version);
    </script>
    The version string usually return's something like this:
    4.0 (compatible; MSIE 5.0; Windows 98; DigExt)

    Can anyone see any problem with using this method?

  2. #2
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes - why not use the index of MSIE to locate it.

    hint:
    ie4 doesn't - i believe - support document.all

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  3. #3
    ...
    Join Date
    Jan 2002
    Location
    London, UK
    Posts
    759
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's a far better way - thanks!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •