0

I can't seem to get a straight answer for this, not sure what I'm doing wrong, but have been searching for a solution for over a month.

I need to call separate stylesheets, pending on the platform (not browser). I have a script I've found that's supposed to do that, but it's not working.

The site is fish-fry.com/dev

the script, which I've placed in my head is:

<script type="text/javascript">

/***********************************************
* Different CSS depending on OS (mac/pc)- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var csstype="external" //Specify type of CSS to use. "Inline" or "external"

var mac_externalcss='http://www.fish-fry.com/dev/wp-content/themes/FISH-FRY-MUSIC-AND-SOUND-CUSTOM-THEME/style.css' //if "external", specify Mac css file here
var pc_externalcss='http://www.fish-fry.com/dev/wp-content/themes/FISH-FRY-MUSIC-AND-SOUND-CUSTOM-THEME/style-windows.css' //if "external", specify PC/default css file here

///////No need to edit beyond here////////////

var mactest=navigator.userAgent.indexOf("Mac")!=-1
if (csstype=="inline"){
document.write('<style type="text/css">')
if (mactest)
document.write(mac_css)
else
document.write(pc_css)
document.write('</style>')
}
else if (csstype=="external")
document.write('<link rel="stylesheet" type="text/css" href="'+ (mactest? mac_externalcss : pc_externalcss) +'">')

</script>

1 Answer 1

0

I'd run that script through jslint.com to start with.
There seems to be quite a few formatting errors.

Also check this out.
Perhaps the useragent is not the place to be checking?

Note: navigator.appVersion.indexOf("Win")

1
  • Thanks for tip @dibs, seems like a good resource to have in your pocket! May 27, 2012 at 0:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.