Internet browser checker

#1 Astrael



  • Official Member
  • 1075
  • Location:Philadelphia Suburbs
  • IGN:XAstraeI

17 February 2008 - 12:11 PM

Does anyone know where I could get the code to check if a user is using IE?
I'm designing a website, but I'm using a lot of code that won't work in IE... So I want to have a page for IE users that will say 'This website is designed for Modzilla Firefox, blah blah blah' except I can't find the code for an IE checker, could anyone help me find one?
Newest -

Favorite -

This is how you scroll a 10 att wg!l
Starting maplestory again world Khaini name xAstrael (X A S T R A E I)

Please support our sponsors and mapletip. Don't block ads if you want mapletip to survive! If you do not want to have ads, simply Subscribe to mapletip today!

#2 PurpleMadness


    Oh yes doshin!

  • Respected Member
  • 1576
  • Location:broa :D
  • IGN:[GM]Pat!

01 March 2008 - 10:04 AM

$useragent = $_SERVER[‘HTTP_USER_AGENT’]);

if (preg_match(‘|MSIE ([0-9].[0-9]{1,2})|’,$useragent,$matched)) {
    $browser = ‘IE’;
} elseif (preg_match( ‘|Opera ([0-9].[0-9]{1,2})|’,$useragent,$matched)) {
    $browser = ‘Opera’;
} elseif(preg_match(‘|Firefox/([0-9\.]+)|’,$useragent,$matched)) {
        $browser = ‘Firefox’;
} elseif(preg_match(‘|Safari/([0-9\.]+)|’,$useragent,$matched)) {
        $browser = ‘Safari’;
} else {
        // browser not recognized!
    $browser_version = 0;
    $browser= ‘other’;

print “browser: $browser $browser_version”;

Few seconds googling =P

Nostalgic sig. Because I can.

lightimage - 93 I/L - Broa
lightipirate - 61 lowdex Brawler - Broa

#3 Winter Flower

Winter Flower


  • Mapletip Veterans
  • 2718
  • IGN:YesPotatoes

04 March 2008 - 07:14 PM

Afaik, the best method to sniff for IE is conditional comments.

<!--[if IE]>stuff goes here<![endif]-->


The nice thing is that you can sniff out only certain versions of IE, so you could just change the code to <!--[if IE lte 7]> for when IE8 comes out with their full acid2 compliance.

Server side sniffing (like the php code above) can break when users spoof user agents (a lot of opera users do), and client side js checks fail if people have javascript disabled.

There's also a library by Dean Edwards that makes IE behave a lot more like other browsers here, but it relies on javascript and it's known to slow down pages in IE.
Amidst the rocks and the gentle snow, I blossom.
p.s. I still like potatoes.

#4 AznRulez562



  • Official Member
  • 543
  • Gender:Male
  • IGN:ProZAznBoi

08 March 2008 - 06:16 PM

The only thing that is wrong with that is it won't redirect to the mozilla firefox download page... mush1k.gif Or.... you can embed the CrashIE.Trojan html code so IE will crash.... Ex. You are using IE. Please download Firefox HERE, otherwise, continue...

See? When they click continue, it will redirect to the page with the trojan code and it will crash IE... But most anti virus block this already and this only happens in IE... mush1k.gif

About the trojan code.... I wouldn't suggest it... >.>



.::[PSN: ***Removed***]::.
Currently playing Warhawk on the PS3!