主题:javacript实现的落叶效果

javacript实现的落叶效果,demo地址如下:http://www.webkaifa.com/ziliao/fallingLeaf.htm
页面源码如下:
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"   
  2. "http://www.w3.org/TR/html4/loose.dtd">  
  3. <html>  
  4. <head>  
  5. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">  
  6. <title>无标题文档</title>  
  7. <style>  
  8. #Layer0 {   Z-INDEX: 10; LEFT: -400px; WIDTH: 100px; POSITION: absolute; TOP: -100px; HEIGHT: 60px}   
  9. #Layer0 {   Z-INDEX: 10; LEFT: -100px; WIDTH: 100px; POSITION: absolute; TOP: -100px; HEIGHT: 60px}   
  10. #Layer1 {   Z-INDEX: 20; LEFT: -100px; WIDTH: 100px; POSITION: absolute; TOP: -100px; HEIGHT: 60px}   
  11. #Layer2 {   Z-INDEX: 30; LEFT: -100px; WIDTH: 100px; POSITION: absolute; TOP: -100px; HEIGHT: 60px}   
  12. #Layer3 {   Z-INDEX: 40; LEFT: -100px; WIDTH: 100px; POSITION: absolute; TOP: -100px; HEIGHT: 60px}   
  13. #Layer4 {   Z-INDEX: 50; LEFT: -100px; WIDTH: 100px; POSITION: absolute; TOP: -100px; HEIGHT: 60px}   
  14. #Layer5 {   Z-INDEX: 60; LEFT: -100px; WIDTH: 100px; POSITION: absolute; TOP: -100px; HEIGHT: 60px}   
  15. #Layer6 {   Z-INDEX: 70; LEFT: -100px; WIDTH: 100px; POSITION: absolute; TOP: -100px; HEIGHT: 60px}   
  16. #Layer7 {Z-INDEX: 70; LEFT: -100px; WIDTH: 100px; POSITION: absolute; TOP: -100px; HEIGHT: 60px}   
  17. </style>  
  18. </head>  
  19. <script>  
  20. xfirst = new Array(80,150,220,310,300,590,680); //初始x位置   
  21. yfirst = new Array(0,180,70,10,50,30,140);  //初始y位置   
  22. xcoor = new Array(80,150,220,310,400,590,680);     
  23. ycoor = new Array(0,180,70,10,50,30,140);   
  24. xdirecnew Array(1,-1,1,-1,1,-1); //初始方向 -1 为左 and 1 为右   
  25. var ns = navigator.appName == "Netscape";   
  26. function doplay()   
  27. {   
  28.     var x,y,i,j,w,h;   
  29.     w = window.screen.width - 100;   
  30. //  w = document.body.clientWidth - 100;   
  31.     h = window.screen.height - 100;   
  32. //  h = document.body.clientHeight - 50;   
  33.     for(j=0;j<7;j++){   
  34.         i=Math.random();                 //随机改变运动方向   
  35.         if (i > 0.95) xdirec[j] = 0 - xdirec[j];     
  36.         x=Math.floor(10*Math.random());   
  37.         y=Math.floor(5*Math.random());  //x和y方向上的随机增量   
  38.         if ( xdirec[j] == 1 ) xcoor[j] = xcoor[j] + x;   
  39.         else xcoor[j] = xcoor[j] - x;   
  40.         ycoor[j] = ycoor[j] + y;        //x越界则变向,y越界则返回   
  41.         if ( xcoor[j] >= w ) {xcoor[j]=w;xdirec[j]=-1;}   
  42.         if ( xcoor[j] <= 0 ) {xcoor[j]=0;xdirec[j]=1;}   
  43.         if ( ycoor[j] >= h ) {xcoor[j]=xfirst[j];ycoor[j]=yfirst[j];}   
  44.         if (!ns){ eval('document.all'+'["Layer'+j+'"]'+'.style.left='+xcoor[j]);   
  45.         eval('document.all'+'["Layer'+j+'"]'+'.style.top='+ycoor[j]);}   
  46.         else {  eval('document.layers'+'["Layer'+j+'"]'+'.left='+xcoor[j]);   
  47.         eval('document.layers'+'["Layer'+j+'"]'+'.top='+ycoor[j]);}   
  48.     }   
  49.     setTimeout('doplay()',100);     
  50. }   
  51. </script>  
  52. <body  onLoad="doplay()">  
  53. <DIV id=Layer0>  
  54. <DD><IMG height=21 src="../images/leaf_0010.gif" width=18> </DD></DIV>  
  55. <DIV id=Layer1>  
  56. <DD><IMG height=22 src="../images/leaf_0010.gif" width=18> </DD></DIV>  
  57. <DIV id=Layer2>  
  58. <DD><IMG height=28 src="../images/leaf_0010.gif" width=25> </DD></DIV>  
  59. <DIV id=Layer3>  
  60. <DD><IMG height=23 src="../images/leaf_0010.gif" width=18> </DD></DIV>  
  61. <DIV id=Layer4>  
  62. <DD><IMG height=22 src="../images/leaf_0010.gif" width=18> </DD></DIV>  
  63. <DIV id=Layer5>  
  64. <DD><IMG height=25 src="../images/leaf_0010.gif" width=18> </DD></DIV>  
  65. <DIV id=Layer6>  
  66. <DD><IMG height=28 src="../images/leaf_0010.gif" width=25> </DD></DIV>  
  67. <DIV id=Layer7>  
  68. <DD><IMG height=28 src="../images/leaf_0010.gif" width=25> </DD></DIV>  
  69. </body>  
  70. </html>  



 
没有dojo学习的qq群
photoshop 视频教程
透明图片展示,网页显示透明图片
DOJO试用手记2--Event System(转)
选择dojo的理由
Dojo学习笔记(2. djConfig详解)
Dojo学习笔记(模块与包)
Dojo学习笔记(dojo.io.IO & jo.io.BrowserIO)
Dojo学习笔记(dojo.lang.array & dojo.lang.func & dojo.string.extras)
Dojo学习笔记( dojo.string & dojo.lang)
Dojo学习笔记(Dojo的基础对象和方法)
dojo学习笔记-dojo.back
浏览器后退保留文本筐内容
Dojo历史介绍
正则表达式基础知识
正则表达式gi是什么意思?
Dojo学习笔记-- djConfig解说
js ===运算符是什么
js二维数组的声明,js奇怪的二维数组的声明
Re:javascript Array.apply函数说明