Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Browser Detection

  1. #1
    Join Date
    Aug 2006
    Location
    Ohio
    Posts
    266
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Browser Detection

    Hello, I am trying to make a script that will display a popup message if the user is on IE 6. I used to know how to do this, but haven't done it in so long that I forgot. I am assuming that it should look something like this:
    Code:
    if (browser detection code = ie6) alert("My text");
    How do I go about finding what browser is being used? Thanks
    Thanks DD, you saved me countless times

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    You can use the following function which will return true if the browser is IE 6.

    Code:
    function isExplorer6() {
    	var appVer = navigator.appVersion;
    	appVer = appVer.split(';');
    	if(appVer[1] == ' MSIE 6.0') {
    		return true;
    	}				
    }

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You really shouldn't use browser detection: it's impossible to completely accurately detect the browser without knowing and testing the features of every browser that does or will exist. To detect IE, I suggest conditional comments:
    Code:
    <script type="text/javascript">
      var ie6 = false;
    </script>
    <!--[if IE eq 6]>
      <script type="text/javascript">
        ie6 = true;
      </script>
    <![endif]-->
    ... but even this should be avoided if possible.
    You can use the following function which will return true if the browser is IE 6.
    Unless the browser is using a different UA string, such as Avant or AOL, of course. Then there's spoofing of the UA to consider, possible future modifications to the browser that might change the format of the UA string slightly...
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Aug 2006
    Location
    Ohio
    Posts
    266
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks guys, both of your information was helpful.
    Thanks DD, you saved me countless times

  5. #5
    Join Date
    Nov 2005
    Location
    Utica, NY
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I want a script that will detect what browser the surfer is using and alert them it is best viewed with browsers and versions i state. is this script the one i want? or can you help me find another better one?

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Please don't do that... there are few "features" of websites that irritate me more. If the site is really unusable in browsers other than the one(s) you've chosen, it's broken. A proper standards-compliant site should work with any browser -- that's the point of standards. If it's still usable but perhaps benefits from features of certain browsers, you might want to make a small note at the bottom of the page that the page has features that will only work in those browsers. There's certainly no need for anything as intrusive as an alert.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    May 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey View Post
    A proper standards-compliant site should work with any browser -- that's the point of standards.
    Seems like a strange position to take in a thread discussing IE6. Microsoft has been cheerfully non-compliant for years.

    A proper standards-compliant site can easily crash in IE6; whether it's a good idea to have one is another subject. At this writing, IE6 seems to be down to an 18% market share, thankfully.

  8. #8
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,881
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    Quote Originally Posted by aarffy View Post
    Seems like a strange position to take in a thread discussing IE6. Microsoft has been cheerfully non-compliant for years.
    So you are saying you can be non-compliant because IE is non-compliant?
    Quote Originally Posted by aarffy View Post
    A proper standards-compliant site can easily crash in IE6.
    What do you want to imply by that? You mean that a non-compliant site has less chance of crashing in IE6?
    ===
    Arie.

  9. #9
    Join Date
    May 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I'm not implying anything. A standards compliant site can easily crash in IE6. There's no point in saying that it can't.

  10. #10
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by Twey View Post
    ...A proper standards-compliant site should work with any browser
    I agree with that completely - until we start talking about IE6. Unfortunately, "should" is your operative word, and in practice it doesn't. It's a lot of extra work to make everything work correctly in older versions of IE and modern browsers.
    Quote Originally Posted by Twey View Post
    There's certainly no need for anything as intrusive as an alert.
    I agree with that too. It's easy enough to turn off stuff that doesn't work in <IE6. And if it's something important, then we can offer a notice via conditional comments.

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
  •