<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>全球搜索,有问必应 (Bing)</title> <style type="text/css"> *{margin: 0;padding: 0;font-family: "微软雅黑";list-style:none;} a:link{color: lightgrey;} a:hover{color: white;} body{background: url(senlin.jpg) fixed;background-position:center center;overflow:hidden} .nav{background-color:#444444;width:100%;height:45px; } .leftNav{margin-left:30px;} .leftNav a{text-decoration: none;font-size:13px;float: left;width:60px;height:45px;line-height:45px;list-style:none;text-align:center;} .teshu a{width:90px;float: left;font-size: 12px;height: 45px;} .logo{background: url(logo.png);width:107px;height: 53px;float: left;margin:120px 0 0 100px;} .shuru{border:0;height:50px;line-height:50px;width:450px;font-color: black;float: left;margin:120px 0 0 15px;font-size:20px;} .subMit{border:0;height:50px;line-height:50px;width:55px;font-color: black;float: left;background-image:url(search-button.jpg);margin:120px 0 0 0;} .button1{width:50px;height:50px;float: right;margin-right: 200px;margin-top: 500px;} </style> <body id="main"> <div> <div> <ul> <li><a href="#">图片</a></li> <li><a href="#">视频</a></li> <li><a href="#">学术</a></li> <li><a href="#">词典</a></li> <li><a href="#">地图</a></li> <li><a href="#">更多</a></li> <li><a href="#">|</a></li> </ul> <ul> <li><a href="#">OfficeOnline</a></li> <li><a href="#">Outlook.com</a></li> </ul> </div> <div> </div> </div> <div> </div> <form> <input type="text"></input> <input type="submit" value=""></input> </form> <div> <img src="button1.png" onclick="changeImage()" > </div> <!--下面是准备创建的函数--> <script> function changeImage() { var n = Math.round((Math.random()*4)); var imgChange = document.getElementById("main"); switch (n) { case 1: imgChange.style.background = url("animals.jpg"); case 2: imgChange.style.background = url("cayuyuan.jpg"); break; case 3: imgChange.style.background = url("lake.jpg"); break; case 4: imgChange.style.background = url("gui.jpg"); break; default: } } </script> </body>