Advanced Browser Detection

Discussion in 'Web Design and Development' started by carlosbutler, Jul 20, 2009.

  1. carlosbutler macrumors 6502a

    carlosbutler

    Joined:
    Feb 24, 2008
    Location:
    London City
    #1
    When I say advanced, I mean one that works properly:rolleyes:

    After reading many tutorial sites and forums on the subject, as well as Firefox documentation (or something along those lines) it turns out that all browsers are rubbish at picking up which browser you are using.

    I was hoping someone could end up doing a script in PHP or JS (preferably in PHP since some have JS turned off) that would easily allow coders to pick up when users with certain browsers access a site. Lets say for example, telling users using IE anything to upgrade and get a better browser:p.

    If anyone has any suggestions, i am sure it would not only help me but many people who are stumped by this.
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    The only browser sniffing I'm doing currently is for IE with some JavaScript. I use it to simply provide a message to users of < IE8.

    PHP:
    if (navigator.appName.indexOf("Microsoft") != -1&&
    parseFloat(navigator.appVersion.split("MSIE")[1]) < 8.0)
    This gets around users who have changed their browser agent as well.
     
  3. carlosbutler thread starter macrumors 6502a

    carlosbutler

    Joined:
    Feb 24, 2008
    Location:
    London City
    #3
    is that PHP or Javascript? im guessing Javascript but you might have some strange php code:p

    how would you actually go about implementing something like that? since, as i said, i have looked around tutorials and things and arent really that useful. even the php.net site (for once) was not that great

    i think this needs to be cleared up and the companies need to sort them selves out
     
  4. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #4
    It's JavaScript, I just like the color coding from the PHP vb Code markup. I place the code at the top of the content section of my page layout (which is automatically included on every page using PHP includes) and do a document.write that simply outputs some verbage about how I don't support IE. It's generally not advised to do too much browser sniffing as it's generally not needed. If you want to see my implementation just check out my site that is in my profile and do a view source.

    There's a bit of a story behind the browser agents and their evolution, though it doesn't make you feel much better knowing the dirty history.
     
  5. savar macrumors 68000

    savar

    Joined:
    Jun 6, 2003
    Location:
    District of Columbia
    #5
    Check out YUI. If anybody has good browser detection, I would expect it to be them. (But that's just a guess.)
     

Share This Page