http://jkisjk.vip.sina.com/html/balls.htm

解决方案 »

  1.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>权当是念经</title>
    </head>
    <body bgcolor=black width=750 height=600>
    <table width=700 height=450>
    <tr><td align=center> <font color=blue size=+2>没事看看几个星星乱飞,就当是念经吧</font></td></tr>
    <tr><td valign=top align=center><br>
    JK祝您快乐<br><br><br>
    <a href="#">很久以前写的代码,没有将边界定这窗口的边界,而是写死边界大小。</a>
    </td></tr>
    </table>
    </body>
    </html>
    <script language=javascript>
    var i,
    ax=new Array(),
    ay=new Array(),
    bx=new Array(),
    by=new Array();
    for(i=0;i<9;i++)
    {
    document.write ("<font id='layer' color=ffffff style='position: absolute; left: -100px; top: -200px; width: 16; height: 18; z-index: -1'>*</font>");
    ax[i]=680*Math.random()+1;
    ay[i]=430*Math.random()+1;
    bx[i]=(5+2*Math.random())*Math.sin(Math.random()*6.28);
    by[i]=(5+2*Math.random())*Math.cos(Math.random()*6.28);
    }
    function fly()
    {
    for(i=0;i<9;i++)
    {
    ax[i]=ax[i]+bx[i];
    ay[i]=ay[i]+by[i];
    if (ax[i]>document.body.clientWidth-20||ax[i]<0) bx[i]=-bx[i];
    if (ay[i]<0||ay[i]>document.body.clientHeight-20) by[i]=-by[i];
    layer(i).style.left=ax[i];
    layer(i).style.top=ay[i];
    }
    setTimeout("fly();",20);
    }
    fly();
    </script>