Jump to content

Simpe function using timer


ze1d

Recommended Posts

Hi all,In this code I should move the "Welcome" text from left to right using a timer:

<html><head><script type="text/javascript">var step = 5;var count = 0;function start(){window.setInterval("run()", 100);}function run(){count += step;ptext.style.left = count;if (count >= 160 || count <= 0){step *= -1;}</script></head><body onload="start()"><p id="ptext" style="position:absolute;">Welcome</p></body></html>

But i don't know whats wrong with it, it's giving me "Object expected" error on the line: <body onload="start()">Thanks very much,zeid

Link to comment
Share on other sites

You forgot the final closing brace after the run() function. Add another } right before the </script> tag.

function run(){count += step;ptext.style.left = count;if (count >= 160 || count <= 0){step *= -1;}}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...