SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot crunch42's Avatar
    Join Date
    Jun 2003
    Location
    San Francisco
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Object Detecting Netscape 6 only

    Anyone know what object should be detected to get Netscape 6 only (not 4 or earlier, and not 7 or Mozilla)?

    Thanks,
    Julian

  2. #2
    SitePoint Guru
    Join Date
    Mar 2004
    Location
    Earth
    Posts
    406
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Taken from http://www.howtocreate.co.uk/tutoria...s/sniffer.html
    Code:
    Netscape 6+, Mozilla and other Gecko
        navigator.product == 'Gecko'
    
    Netscape 6, Mozilla 0.9- and reduced Gecko
        navigator.product == 'Gecko' && !window.find
    
    Netscape 7+, Mozilla 1+ and advanced Gecko
        navigator.product == 'Gecko' && window.find
    But if you're only interested in Netscape, and not equivalent mozilla builds, you'll probably have to look for "netscape" in the user-agent string. You'd end up with something like this:
    Code:
    var ua = navigator.userAgent.toLowerCase();
    var ns6 = ( navigator.product == 'Gecko' && !window.find && /netscape/.test(ua) );
    Can I ask why you need to detect that specifically?

  3. #3
    SitePoint Zealot crunch42's Avatar
    Join Date
    Jun 2003
    Location
    San Francisco
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To be able to include a polite note in boldfaced large red text asking the user to please consider upgrading from their horribly obsolete browser.

    By the way the info. you've provided doesn't use Object Detection--it uses sniffing, which is not the technique I want to use. Thanks, though.

  4. #4
    SitePoint Guru
    Join Date
    Mar 2004
    Location
    Earth
    Posts
    406
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes I'm aware of the difference, but as far as I know there is no object test to differentiate netscape builds from non-netscape builds. I understand why you might prefer object testing - but be careful of rejecting or embracing a solution simply because of its reputational baggage: just because user-agent sniffing has been misused in the past, that doesn't mean it's always the wrong approach; just because object-testing is generally more reliable and future-proof, that doesn't mean it's always the right approach.

    Anyway, in my humble opinion "please upgrade your browser" messages are pointless - most people don't know what it means, and people who do know what it means will probably never see it. Better to degrade gracefully

  5. #5
    SitePoint Guru bronze trophy blufive's Avatar
    Join Date
    Mar 2002
    Location
    Manchester, UK
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want to pick out a particular release of a particular browser, then user-agent sniffing is probably the best way to do it.

    For many (most) purposes, object detection is to be preferred, since you should operate on the basis of what a browser is capable of doing, rather than what it's called. If you want to do whizzy DHTML, or stretch the limits of [insert web technology here], then I agree you should test the support for it on the fly, rather than picking out [n] browsers to support.

    But if you're specifically looking for Netscape 6.0, rather than "any browser which supports the foo.bar object but not the bar.baz() DOM method" then just hold you nose and do a bit of user-agent sniffing. It's what it's there for, and it's far less likely to kick out RareBrowser 3.75 (which will be released in 4 months time) just because of some quirk in its object support.

  6. #6
    SitePoint Zealot crunch42's Avatar
    Join Date
    Jun 2003
    Location
    San Francisco
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the opinions.


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
  •