Browser detect problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • KoRnDragon

    Browser detect problem

    I'm using a script to detect which browser is using in order to include
    the correct stylesheet but on this one page
    (http://korndragon.com/ffa5.php) It thinks I'm using Internet Explorer
    when I'm really using FireFox. I have the same script included on all
    pages on my site and it's never messed up before. In fact It's included
    inside the nav, so nothing was changed.

    The script itself: http://korndragon.com/style.php (view source and you
    can see the comment of which stylesheet is being used)

    The source: http://www.sitepoint.com/article/bro...uck-php-rescue

    Anyway, it's just that one page that it's included on thinks I'm using
    Internet Explorer (I've asked others and they said it's doing the same
    thing) I included the script (style.php) at the top of the page so it's
    easier to find the commented source.

    Any ideas?

    Thanks in advance.

  • John Dunlop

    #2
    Re: Browser detect problem

    KoRnDragon:
    [color=blue]
    > I'm using a script to detect which browser is using in order to include
    > the correct stylesheet but on this one page
    > (http://korndragon.com/ffa5.php) It thinks I'm using Internet Explorer
    > when I'm really using FireFox.[/color]

    Search for (Internet Explorer) conditional comments.

    --
    Jock

    Comment

    • KoRnDragon

      #3
      Re: Browser detect problem

      I'm using FireFox when it does that though. I wouldn't be having a
      problem if I was using IE and it thought I was using IE. I'm using
      FireFox and it thinks I'm using IE.

      Comment

      • Michael Winter

        #4
        Re: Browser detect problem

        On 07/06/2006 20:06, KoRnDragon wrote:
        [color=blue]
        > I'm using a script to detect which browser is using [...][/color]

        Server-side? Good grief! It's bad enough trying to perform browser
        detection client-side.
        [color=blue]
        > in order to include the correct stylesheet but on this one page
        > (http://korndragon.com/ffa5.php)[/color]

        You would be better off rewriting that to trigger 'Standards' mode
        (preferably by using, and authoring to, the Strict HTML document type),
        and writing both valid markup and CSS (you have managed neither). Use a
        decent browser like Opera or Firefox, and fix-up as necessary for IE.

        If you rely on browser quirks to render your site, you are bound to
        encounter problems. Writing different style sheets for various browsers
        requires unnecessary effort, makes ongoing maintenance more taxing, and
        you have no chance of coping with all user agents that might visit your
        site. The point of conforming with interworking standards and guidelines
        is to eliminate all of that[1].

        [snip]
        [color=blue]
        > The source: http://www.sitepoint.com/article/bro...uck-php-rescue[/color]

        Browser detection is unreliable, especially server-side. User agents
        spoof others; Microsoft started it all. It is an inescapable fact.
        Making a site functionally dependent upon browser detection is a serious
        mistake.

        [snip]

        Mike


        [1] I don't pretend that conforming to standards is a panacea,
        but it is surely a better starting point than browser
        detection, or writing unnecessary hacks.

        --
        Michael Winter
        Prefix subject with [News] before replying by e-mail.

        Comment

        • John Dunlop

          #5
          Re: Browser detect problem

          KoRnDragon:
          [color=blue]
          > I'm using FireFox when it does that though. I wouldn't be having a
          > problem if I was using IE and it thought I was using IE. I'm using
          > FireFox and it thinks I'm using IE.[/color]

          I realise that. I was suggesting that you could use conditional
          comments to serve Internet Explorer-only content (including styles
          overruling non-Internet Explorer styles). Other browsers should treat
          the content as a comment, since that is what it is as far as HTML4.01
          is concerned.

          That said, browser detection is not only doomed to failure but also
          probably a mistake. As Michael Winter has pointed out, moving browser
          detection based on the User-Agent header from client-side to
          server-side does not overcome any of its problems, because browsers
          still pretend to be each other. The mistake, I think, is making more
          work for yourself than you really need.

          --
          Jock

          Comment

          Working...