Jump to content


Browser Detection Problems!


3 replies to this topic

#1 T-Rizzle

    Young Padawan

  • Members
  • Pip
  • 36 posts
  • Location:Madison, SD

Posted 11 December 2006 - 02:32 PM

I'm having some problems with a browser detect code I'm using. I know that it doesn't really fall into the CSS category specifically but it deals with loading stylesheets based upon the browser detected.

I have it setup so I load three different css documents (external) when IE 6 is detected, IE7 is detected, and Netscape (firefox mainly). The only problem I'm getting is it will load the IE6 and IE7 stylesheets respectively, but it won't load the Firefox one. Someone please help me out, maybe I'm overlooking something but it should work I think. Thanks. Look below for the code.....

<!–[if IE 6]>
<link rel="stylesheet" type="text/css" href="css/greendotIE.css" />
<![endif]–>

<![if !IE 6]>
<link rel="stylesheet" type="text/css" href="css/greendotFF.css" />
<![endif]>

<![if lte IE 7.0]>
<link rel="stylesheet" type="text/css" href="css/greendotIE7.css" />
<![endif]-->

#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 11 December 2006 - 02:38 PM

Well, to start, conditional comments only work with IE. So all firefox sees there is a comment.
Try loading the FF one regardless of what happens, then optionally load the IE ones and overwrite all of the properties set in the FF one through those.

#3 T-Rizzle

    Young Padawan

  • Members
  • Pip
  • 36 posts
  • Location:Madison, SD

Posted 11 December 2006 - 02:44 PM

Ok, well that makes some more sense. I tried just loading the stylesheet regularly and now it will only work in Firefox, not IE6 & 7. I'll probably need to run a full javascript in order to get it to work properly. If IE 6 & 7 wouldn't be so damn different none of this would be a problem! If anyone could help me out it would be greatly appreciated!

Edited by T-Rizzle, 11 December 2006 - 02:50 PM.


#4 T-Rizzle

    Young Padawan

  • Members
  • Pip
  • 36 posts
  • Location:Madison, SD

Posted 11 December 2006 - 03:42 PM

Found the solution to my problem! I figured I'd post the working code in case anyone else ever has a similar problem.

<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href=" ../css/greendotIEcontactus.css" />
<![endif]-->

<!--[if !lt IE 7]>
<link rel="stylesheet" type="text/css" href=" ../css/greendotIE7contactus.css" />
<![endif]-->

<![if !IE]>
<link rel="stylesheet" type="text/css" href="../css/greendotFFcontactus.css" />
<![endif]>





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users