SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2005
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    browser detection

    I'm trying to writ a browser detection script and it seems to work but I was wondering if there is an easier way and/or if this was right.

    Code:
    <!--
    //let's see what browser we have first (firefox test)
    if (navigator.appName != "Netscape" || navigator.appVersion <= "5.0") {
    	//let's see what IE browser they are running
    	if(navigator.userAgent.indexOf("MSIE 6.0") < 6.0) {
    	// show CSS header on page to display message and browser links
    	window.alert("browser out of date!") //testing message;
    		}
    	}
    }
    -->

    The line in question is

    Code:
    if(navigator.userAgent.indexOf("MSIE 6.0") < 6.0) {
    -->
    What I would like to do is show a message for IE older than 6.0 but all other attempts have failed with a syntax errors. It doesn't seem to be right because it only will test for 6.0 and ignore all others.

    I'm working with a guy that has a client that still uses 5.2 on a mac, and they have several client using old browsers who say the page doesn't display properly. If that helps i any way.

    I know there are several browser scripts out there but I am new to javascript and to copy and paste wouldn't help me understand the language so I decided to write my own instead so please excuse the neophyte question.

    Thank you all in advance.

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,988
    Mentioned
    186 Post(s)
    Tagged
    2 Thread(s)

    conditional comments

    Browser detection is not best practice. It's better to test for what is supported. But if you are only doing this to apply different CSS forr older browsers, I think using conditional comments is the way to go. AFAIK only IE recognises "conditional comments". should bring up a lot of results, but you could start here. http://msdn.microsoft.com/workshop/a...omment_ovw.asp

  3. #3
    SitePoint Zealot
    Join Date
    Apr 2005
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see your point that it should be done that way. In fact the site is not displaying properly mostly becasue of IE's incorrect box model. But since the project is already completed (and I should have checked IE 5 anyway I guess) I was looking for a less unobtrusive way to just make people aware that their browser was out of date. Rather than adding a bunch if IE specific comments to the page.

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,988
    Mentioned
    186 Post(s)
    Tagged
    2 Thread(s)

    upgrading

    Maybe you and I both know they should upgrade, but they may not want or be able to. My brother has an old computer that is so low on memory that he can't upgrade unless he deletes the existing software first. Plus he's comfortable with what he knows and isn't so keen on the idea of "risking" an attempt to upgrade. He knows how to log on but not much more. It may be better to do a little extra work and not risk upsetting the "old fashioned" folks. Even if you tell them it's their fault if it doesn't look/behave right, a part of them will still think it's your fault for not doing it right. After all, other sites look OK.


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
  •