Jump to content

Trying to select diff style sheet depending on browser detection


pafruu

Recommended Posts

Hi I need help,I am trying to make my website detect if the user is using safari or not. If the user does use safari then I want the site to use a different stylesheet. here is what I got so far:<script type="text/javascript">function detectBrowser(){var browser=navigator.appName;var b_version=navigator.appVersion;var version=parsefloat(b_version);if ((browser=="Safari")){document.write("<link href="img/stylesaf.css" rel="stylesheet" type="text/css" />");}{document.write("<link href="img/style.css" rel="stylesheet" type="text/css" />");}}</script>when I load up the page on my browser its as if the style sheet doesnt exist at all...*edit* <body onload="detectBrowser()"> I forgot to write that I do call the function on load *edit*please help

Link to comment
Share on other sites

You would be much better off doing hte detection n the server side because if the client has JS turned off this is not going to work.
your right, because the hack, I just checked doesnt work aaaargh :)
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...