随机切换网页背景图片的JS代码

时间:2022-11-16 19:14:55
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>随机切换网页背景图片的JS代码</title>


</head>
<body>


<script language="javascript">
now = new Date();
erke = now.getSeconds();
erke = erke - parseInt(erke/3)*3 + 1;//定义张数
document.write("<div style='background:url(images/bg"+erke+".png) no-repeat;' id=Change></div>")
</script>


<!--这里放背景上面的内容-->
<div  id=Change>
  
</div>


<style type="text/css">
<!--
body {margin: 0px;}




-->
</style>
</body>
</html>