当前位置: 首页 > 图文教程 > 网络编程 > Javascript > Dhtml+Js算法:5个小球运动的简化版,变通实现更简单的飞行的图片

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 中的 Dhtml+Js算法:5个小球运动的简化版,变通实现更简单的飞行的图片


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-10   浏览: 520 ::
收藏到网摘: n/a

<!--图片下载需用时,请少等片刻即看到效果-->

<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='/A-A-A/2005/07/17/20050717100744102147_1.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>