Forums

CSS

This topic is locked

Link to different css file based on browser

Posted 29 Apr 2005 08:24:47
1
has voted
29 Apr 2005 08:24:47 Simon Howell posted:
I'm wondering if there is a script that controls which css file is linked to in the head of an HTML page based on browser detection. Any help would be appreciated.

STUDIO MX 2004

Replies

Replied 29 Apr 2005 15:02:31
29 Apr 2005 15:02:31 Matt Bailey replied:
There's a free extension right on this very site: <pre id=code><font face=courier size=2 id=code>www.dmxzone.com/ShowDetail.asp?NewsId=6748</font id=code></pre id=code>

Hope it helps.

___________________________________
* Sorry... how do you do that again?... *
Replied 29 Apr 2005 18:56:11
29 Apr 2005 18:56:11 Simon Howell replied:
Thanks Matt, that would have been nice, but I need something for a regular HTML page and not PHP. I'll keep looking.

STUDIO MX 2004
Replied 29 Apr 2005 21:20:01
29 Apr 2005 21:20:01 Matt Bailey replied:
I guess the usual way to do it then would be with javascript. Try googling for 'javascript css on browser' or similar.

___________________________________
* Sorry... how do you do that again?... *
Replied 30 Apr 2005 02:27:58
30 Apr 2005 02:27:58 Simon Howell replied:
I found this one that seems to work quite well. Thanks.

&lt;script language="JavaScript"
type="text/JavaScript"&gt;
if(navigator.appName == "Microsoft Internet Explorer" {
document.write("&lt;link href=\"ie.css\" rel=\"stylesheet\" type=\"text/css\" /&gt;";
}
else {
document.write("&lt;link href=\"nn.css\" rel=\"stylesheet\" type=\"text/css\" /&gt;";
}
&lt;/script&gt;

STUDIO MX 2004

Reply to this topic