0

我似乎无法得到一个直接的答案,不确定我做错了什么,但一个多月来一直在寻找解决方案。

我需要调用单独的样式表,在平台(而不是浏览器)上挂起。我有一个脚本,我发现它应该这样做,但它不起作用。

该网站是fish-fry.com/dev

我放在脑海中的脚本是:

<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>
4

1 回答 1

0

将从 jslint.com开始运行该脚本。
似乎有很多格式错误。

也检查一下
也许用户代理不是要检查的地方?

注意:导航器。appVersion .indexOf("Win")

于 2012-05-27T00:02:41.420 回答