|
<!--图片下载需用时,请少等片刻即看到效果-->
<HTML> <HEAD> <META http-equiv=Content-Type content=text/html;charset=gb2312> <Meta name=Gemeratpr content=网络程序员伴侣(Lshdic)2004> <TITLE>网页飞行图片</TITLE> <STYLE> *{font-size:12px;color:;} a{text-decoration:none;} a:hover{color:red;} </STYLE> </HEAD> <BODY topmargin=2 leftmargin=2> <BASE target=_top> <div id=a style=table-Layout:fixed;width:100%;height:100%;border:1 solid black></div> <script> //原作:风云舞,载自:http://www.lshdic.com/bbs var wid1,hei1,str1="",xx=0,yy=0,xjia=true,yjia=true //定义全局变量,为提高运行速度 wid1=a.offsetWidth-70;hei1=a.offsetHeight-70 //得到容器的宽和高 //首次向容器内塞进1个飞行的图片,图片位置属性是随机的 tempx=Math.round(Math.random()*wid1);tempy=Math.round(Math.random()*hei1); str1+="<a href=http://www.lshdic.com/bbs target=_blank><img src=/Upload/2005-06/user30.gif style=position:absolute;left:"+tempx+";top:"+tempy+";z-index:10;width:150;height:150; id=img1 border=0></a>" a.innerHTML=str1; //插入STR1,STR1?个VML球的代码 function play1(){ //播放函数 wid1=a.offsetWidth;hei1=a.offsetHeight if(wid1-xx<155)xjia=false //到达X极限,值为FALSE if(xx<5)xjia=true //到达X起点,值为TRUE if(hei1-yy<155)yjia=false if(yy<5)yjia=true if (xjia==true)xx+=5;else xx-=5 //TRUE的话就++,FALSE的话就-- if (yjia==true)yy+=5;else yy-=5 img1.style.left=xx;img1.style.top=yy //更新球的位置 } setInterval("play1()",10) //10毫秒播放一次,一般CPU保证能消化~~~ </script> </BODY> </HTML>
|