Page

Browser based CSS Switcher

In case your site isn’t viewed the same in all browsers .. and you have made more than 1 CSS file and you don’t know how to apply them now this small tutorial will teach you how.
It’s quite simple … follow the code below:

<?
if ($name = strstr ($HTTP_USER_AGENT, "MSIE"))
{
?>
<link rel="stylesheet" href="internetexplorer.css">
<?
}
else if ($name = strstr ($HTTP_USER_AGENT, "Mozilla"))
{
?>
<link rel="stylesheet" href="mozilla.css">
<?
}
else
{
?>
<link rel="stylesheet" href="otherbrowsers.css">
<?
}
?>

You can see this simple code in action on Sava’s Place also. If you open up the site in Internet Explorer you will see a small add in the header (right below the login box). If you open it up in Mozilla … the ad is gone… pretty neat ha ? ;)

Stay Connected

Subscribe to RSS Feed

Subscribe to RSS Feed

Follow me on Twitter

Follow me on Twitter

Subscribe via e-mail

Subscribe via e-mail

Comments One Response to “Browser based CSS Switcher”

  1. Nice Idea


Post your comment

Leave a Reply

ss_blog_claim=35efd881137b13aae56d7e24920f8a2b