166、图片左右飞舞

166、图片左右飞舞

脚本说明:

第一步:把如下代码加入<body>区域中

<script language="JavaScript">

 var pos1=-95;

 var pos2=-95;

 var pos3=-95;

 var pos4=-95;

 

 var speed1 = Math.floor(Math.random()*10)+2;

 var speed2 = Math.floor(Math.random()*10)+2;

 var speed3 = Math.floor(Math.random()*10)+2;

 var speed4 = Math.floor(Math.random()*10)+2;

 

  function next() {

    pos1 += speed1;

    pos2 += speed2;

    pos3 += speed3;

    pos4 += speed4;

 

    if (pos1 > 795) pos1 = -95;

    if (pos2 > 795) pos2 = -95;

    if (pos3 > 795) pos3 = -95;

    if (pos4 > 795) pos4 = -95;

 

    if (document.layers) {

       document.layers[0].left = pos1;

       document.layers[1].left = pos2;

       document.layers[2].left = pos3;

       document.layers[3].left = pos4;

 

    }

    else {

       mouse1.style.left = pos1;

       mouse2.style.left = pos2;

       mouse3.style.left = pos3;

       mouse4.style.left = pos4;

 

    }

    window.setTimeout("next();",10);

 }

 </script>

 <div id="mouse1"

style="HEIGHT: 100px; LEFT: 0px; POSITION: absolute; TOP: 165px; WIDTH: 100px">

<dd><img alt border="0" src="image1.gif" width="30" height="30"> </dd>

</div><div id="mouse2"

style="HEIGHT: 100px; LEFT: 0px; POSITION: absolute; TOP: 250px; WIDTH: 100px">

<dd><img alt border="0" src="image2.gif" width="72" height="32"></dd>

</div><div id="mouse3"

style="HEIGHT: 100px; LEFT: 0px; POSITION: absolute; TOP: 333px; WIDTH: 100px">

<dd><img alt border="0" src="image3.gif" width="72" height="32"></dd>

</div><div id="mouse4"

style="HEIGHT: 100px; LEFT: 0px; POSITION: absolute; TOP: 415px; WIDTH: 100px">

<dd><img alt border="0" src="image4.gif" width="72" height="32"></dd>

</div>

 

 

第二步:把<body>区域中的内容改为

<body bgcolor="#fef4d9" onload="next();">

 

Write a comment

Comments: 0