难点在于document.write输出html语句结构用法。。。思路在于在网页中动态加入xxx.css文件..来实现.
以下是引用片段: <script language="javascript"> var styleId=1; var cssPath="style/style_switch"; document.write(’<link href="’+cssPath+styleId+’.css" type="text/css" rel="stylesheet" id="cssLink" media="screen" />’); //默认调用第一个 function styleChange(n){ var cssLink=document.getElementById("cssLink"); // alert("1"); cssLink.href=cssPath+n+".css"; alert(cssLink.href); } </script> |