Forum Moderators: coopster

Message Too Old, No Replies

Serving different style sheets to different browsers

         

John_Creed

9:45 am on Jun 9, 2004 (gmt 0)

10+ Year Member



I've searched the forums but can't find the answer to my question. I have two different style sheets, I would like all IE users to receive style1.css, while everyone else receives style2.css.

I don't need a different one for each browser, just one for IE and one for everyone else!

I'm not very good with PHP, does anyone know the correct syntax for this if/else statement?

Timotheos

3:44 pm on Jun 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could use the get_browser() function.

<?php
$userinfo = get_browser();

if ($userinfo->browser == 'IE')
$css_file = 'style1.css';
else
$css_file = 'style2.css';
?>

<head>
<title>You get what you get</title>
<link rel="STYLESHEET" type="text/css" href="<?=$css_file?>">
</head>