我写了这个功能,从右上角飞DIV到左下:的Javascript:复读功能不起作用
var myObj;
function infly() {
myObj=document.getElementById('mydiv');
myObj.style.right='0px';
myObj.style.top='0px';
}
function flyer() {
var x=parseInt(myObj.style.right);
var y=parseInt(myObj.style.top);
x+=1;
y+=1;
myObj.style.right=x+'px';
myObj.style.top=y+'px';
}
function repeat()
{
setTimeout(flyer,5000)
}
和HTML代码是:
<body onLoad="infly()">
<div id="mydiv">
</div>
<a href="" onClick="javascript:repeat()">Fly</a>
...
..
.
但repeat
功能无法正常工作。当我每次点击删除此功能时,我的DIV都能正确地飞行。
我试用setInterval('fly();', 10);
但没有成功。
感谢您的帮助。
更新:
我编辑的代码与正确的repeat
功能,但还是不行。
我编辑的代码,但不能工作 – Nulled 2011-12-28 09:41:33