以下是代码
<!DOCTYPE html PUBLIC "-//W3C//DTD html 4.0 Transitional//EN">
<html>
 <head>
  <title> 自由落体模拟 </title>
  <meta name="Generator" content="EditPlus">
  <script type="text/javascript">var i = null;
function analog(ex,ey,tx,vx) {
var o=document.getElementById('box');
o.style.right='0px';
o.style.bottom='60px';
i&&clearInterval(i);
var dy=3,k=1,ex=(ex>0&&ex<1)?ex:0.2,ey=(ey>0&&ey<1)?ey:0.5,tx=(tx>20 && tx<500)?tx:30;
i=setInterval(function(){
if(o){
    var r=parseInt(o.style.right)+vx,b=parseInt(o.style.bottom)+dy*Math.pow(-1,k);
                                dy=dy+2*Math.pow(-1,k+1);
                                o.style.right=r+'px';
o.style.bottom=b+'px';
                                if(r>500)clearInterval(i);
                                if(b<=-200)
                                {
                                k++;dy=dy*ey;vx=vx*ex;
                                };
                                if(dy<=0)
                                {
                                dy=0,k++;
                                }
                             }
},tx);
}
 </script>
 </head>
 <body>
<p>水平恢复系数ex:<input id="ex" type="text" value="0.5" /> (0-1)</p>
<p>垂直恢复系数ey:<input id="ey" type="text" value="0.5" /> (0-1)</p>
<p>函数周期tx:<input id="tx" type="text" value="30" />(20-500)</p>
<p>初始水平方向速度vx:<input id="vx" type="text" value="5">
<input type="button" value="analog" onclick="analog(document.getElementById('ex').value, document.getElementById('ey').value, document.getElementById('tx').value,document.getElementById('vx').value;)" /></p>
<div style="margin-left:900px;">
<div id='box' style="width:30px; height:30px; background:#000000; position:relative; right:0px; bottom:60px"></div>
</div>
</body>
</html>
这个代码要来让小球做平抛运动,多次反弹后静止。现在代码不能运行。而且有几个函数是引用的,自己也不懂。
那个i&&setInterval是什么意思。还有if(o)是什么意思,大神帮忙哈!JS