I wrote this function to fly DIV from top right to bottom left:
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)
}
And HTML code is:
<body onLoad="infly()">
<div id="mydiv">
</div>
<a href="" onClick="javascript:repeat()">Fly</a>
...
..
.
But repeat function not work. When I remove this function in every click my DIV fly correctly.
I try with setInterval('fly();', 10); but no success.
Thanks for any helps.
Update:
I edit the code and correct repeat function but still not work.