Detect Browser (FF, IE, Etc)

Discussion in 'Programming' started by TrafficToplist.com, Apr 6, 2007.

  1. #1
    Hey guys, i was wondering if there was a script I could use that would show different content for IE. I want it to have something just for IE users saying something like "This site works best with FF <link>". This is because my site works perfect in Firefox, but has one stupid graphical glitch in IE!!! I don't care about netscape though, not even going to try and see what it looks in that lol. In my old site at least, less than 10% used Netscape, opera, and all other random browsers.

    I've seen a script that will crash only IE users, but I don't know if I want to go that far lol. Thanks in advance to any replies!
     
    TrafficToplist.com, Apr 6, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
    <?php
    
    if (preg_match('/MSIE/i', $_SERVER['HTTP_USER_AGENT']))
    {
         echo 'This site works best with FF <link>';
    }
    
    ?>
    
    PHP:
    Untested.
     
    nico_swd, Apr 6, 2007 IP
  3. TrafficToplist.com

    TrafficToplist.com Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Cool, thanks man! Don't know about older versions of IE, but works perfect when I tested it! :) My pages are all in PHP, so this is perfect for my site!
     
    TrafficToplist.com, Apr 6, 2007 IP
  4. LuGeLaS

    LuGeLaS Peon

    Messages:
    242
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    thanks good
     
    LuGeLaS, Apr 6, 2007 IP
  5. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #5
    Graphical glitch? In the old days (about 3 or 4 months ago) I would tell yo to implement a CSS hack to defer X browser's style from Y browser's style - but now I know the pwoer behind Conditional Comments. Essentially, you can say All browser do this - but IE Whatever ver you want.... do This (so you can specifically specify IE 6.0 - do this or IE 5.5 or Greater do This, etc...)
     
    ccoonen, Apr 6, 2007 IP