日期:2014-05-16  浏览次数:20336 次

用JS写一个按每个星期换一张背景图片
<html>
<body>

<script   type= "text/javascript ">

var   d=new   Date()
var   weekday=new   Array(7)
weekday[0]= "Sunday "
weekday[1]= "Monday "
weekday[2]= "Tuesday "
weekday[3]= "Wednesday "
weekday[4]= "Thursday "
weekday[5]= "Friday "
weekday[6]= "Saturday "
document.write( "Today   it   is   "   +   weekday[d.getDay())

</script>

</body>
</html>
请参考这个例子,,谢谢啦

------解决方案--------------------
<script type= "text/javascript ">
var = bg;
switch(d.getDay())
{

case 0:
bg = "a0.jpg ";
break;
case 1:
bg = "a1.jpg ";
break;
case 2:
bg = "a2.jpg ";
break;
case 3:
bg = "a3.jpg ";
break;
case 4:
bg = "a4.jpg ";
break;
case 5:
bg = "a5.jpg ";
break;
case 6:
bg = "a6.jpg ";
break;


}

xxx.style.background = "bg ";
</script>

---

xxx是你要替换的背景的对象