Server-side Stylesheet Switcher

liunx

Guest
I am looking for a tutorial/piece of code/something i can look at that will teach me how to make a stylesheet switcher. The idea for this one is that there will be two stylesheet choices - one for IE and one for good browsers - and, when the page is loaded, the server can automatically detect whether the user is on IE or on a good browser and load the correct stylesheet. This needs to be accomplished with something other than PHP. Other technologies available are ASP and JS.

I've searched the forums here and have not found links to resources that could assist me with this. If anybody here has come across a site that features something like this or if they know a good place to start learning how to build one, please post and help a fella out.

Thanks!just curious... what's the hating on PHP?it's not available on the server i'm working with :)
other than that i like itYou could use IE conditional comments.

Make a stylesheet for regular browsers and then make another with any necessary changes for IE. Put thjis link just before your closing head tag : <!--[if gte IE 5]]>
<link href=http://www.webdeveloper.com/forum/archive/index.php/"ieonly.css" rel="stylesheet" type="text/css">
<![endif]-->hey BonRouge,

thanks, but no luck - this does not work. It just says a bunch of text at the top of the screen.

For clarification, I'm using IE6 and the finished site needs to be compatible with IE5.5/IE6.Found the answer - posting here for future reference.


<script type="text/javascript">
<!--// Stylesheet Switcher
if ((navigator.appName).indexOf("Microsoft")!=-1) {
document.write('<link rel="stylesheet" href=http://www.webdeveloper.com/forum/archive/index.php/"styleIE.css" type="text/css">');
}
else {
document.write('<link rel="stylesheet" href=http://www.webdeveloper.com/forum/archive/index.php/"style.css" type="text/css">');
}
//-->
</script>
<noscript>
<link rel="stylesheet" href=http://www.webdeveloper.com/forum/archive/index.php/"style.css" type="text/css">
</noscript>


stick this in the header of the HTML document.Yeah right...
And users who have IE and browse with JS disabled will get "wrong" style?hey BonRouge,

thanks, but no luck - this does not work. It just says a bunch of text at the top of the screen.

For clarification, I'm using IE6 and the finished site needs to be compatible with IE5.5/IE6.
Hey kendo,
It does work.
I wouldn't rely on javascript to do that.
Good luck.that's not server side... Just make a little ASP statement. You could even use serverside javascript
 
Back
Top