pafruu Posted March 11, 2008 Share Posted March 11, 2008 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 More sharing options...
pafruu Posted March 11, 2008 Author Share Posted March 11, 2008 actually its ok, i went with a css hack and it works Link to comment Share on other sites More sharing options...
aspnetguy Posted March 11, 2008 Share Posted March 11, 2008 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. Link to comment Share on other sites More sharing options...
pafruu Posted March 11, 2008 Author Share Posted March 11, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.