Tryit Editor v1.4

<html> <head> <script type="text/javascript"> var i=1 function starttimer() { document.getElementById('h_one').style.position="relative"; document.getElementById('h_one').style.left=+i; document.getElementById('h_two').style.position="relative"; document.getElementById('h_two').style.top=+i; i++; timer=setTimeout("starttimer()",10); } function stoptimer() { clearTimeout(timer); } </script> </head> <body onload="starttimer()" onunload="stoptimer()"> <h1 id="h_one">Header one</h1> <h1 id="h_two">Header two</h1> </body> </html> | Your Result:
Edit the code above and click to see the result. | W3Schools.com - Try it yourself