stevenhwang

收集C#、SQL、JavaScript、HTML、CSS点点滴滴

导航

CSS换肤

Posted on 2006-12-22 14:12  stevenhwang  阅读(189)  评论(0)    收藏  举报
CSS换肤
(我想可以换肤的网站,原理应该是这样吧)

<html>
<head>
<script language="javascript">
var url = document.location.toString();
var style = url.substr(url.length-1, 1);
switch (style)
{
 case "1":
  document.write('<style>@import "css1.css";</style>');
  break;
 case "2":
  document.write('<style>@import "css2.css";</style>');
  break;
 default:
  document.write('<style>@import "css0.css";</style>');  
}
</script>
</head>
<body>
<div width="100%">这里是文字</div>
<input type="button" value="css1" onClick="document.location='http://127.0.0.1/test.htm?css=1'">
<input type="button" value="css2" onClick="document.location='http://127.0.0.1/test.htm?css=2'">
<input type="button" value="default" onClick="document.location='http://127.0.0.1/test.htm'">
</body>
</html>