var iSpeedX=6;
var iSpeedY=8;
var timer=null;
function startMove()
{
var oDiv = document.getElementById("div1");
timer=setInterval(function(){
iSpeedY+=3;
var l = oDiv.offsetLeft+iSpeedX;
var t = oDiv.offsetTop+iSpeedY;
if(l>document.documentElement.clientWidth-oDiv.offsetWidth)
{
iSpeedX*=-0.8;
l=document.documentElement.clientWidth-oDiv.offsetWidth
}
else if(l<0)
{
iSpeedX*=-0.8;
l=0;
}
if(t>document.documentElement.clientHeight-oDiv.offsetHeight)
{
iSpeedY*=-0.8;
iSpeedX*=0.8;
t=document.documentElement.clientHeight-oDiv.offsetHeight;
}
else if(t<0)
{
iSpeedY*=-0.8;
t=0;
}
if(Math.abs(iSpeedX)<1)
{
iSpeedX=0;
}
if(Math.abs(iSpeedY)<1)
{
iSpeedY=0;
}
if(iSpeedX==0&&iSpeedY==0&&t==document.documentElement.clientHeight-oDiv.offsetHeight)
{
clearInterval(timer);
alert("停止");
}
oDiv.style.left=l+"px";
oDiv.style.top=t+"px";
document.title=iSpeedX;
},30);
};