Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

timed text 1

Status
Not open for further replies.

peitzza

Technical User
Apr 13, 2000
80
US
is there any way i can make an animation with text using JS without getting to long of a script(more than 50 lines)?<br><br>what i want to do is have a &quot;W&quot; appear and then two seconds later an &quot;E&quot; then two second later an &quot;L&quot; and so on to spell &quot;WELCOME&quot;?<br><br>any suggestions would be greatly appreciated, thanx in advance, peter <p>Peter Heaton<br><a href=mailto:heaton@characterlink.net>heaton@characterlink.net</a><br><a href= it how ever you want</a><br>
 
Dear Peter,<br><br>Is this a class assignment? If so I don't want to show the code.<br><br>In the IE browser it shouldn't take any where near 50 lines. Store the string and a position variable in script global variables and set the elements.innerText property to the current substring of the global string and encrement the position. Then if there are more positions left reset the timeout.<br><br>Good luck in Netscape without using an <input type=text> element to display the text.<br><br>If this is not a class assignment let me know and I can provide sample code.<br><br>-pete<br>
 
no it's not a class assignment...<br><br>i would really appreciate seeing the script as i'm new to javascript.<br><br>no big rush though... <p>Peter Heaton<br><a href=mailto:heaton@characterlink.net>heaton@characterlink.net</a><br><a href= it how ever you want</a><br>
 
Here ya go:<br><br>&lt;script language=javascript&gt;<br>&lt;!--<br>var g_msg = new String(&quot;W E L C O M E&quot;);<br>var g_pos = 1;<br><br>function displayNextMsg(){<br>&nbsp;&nbsp;document.all(&quot;msgDisplay&quot;).innerText = <br>&nbsp;&nbsp;&nbsp;&nbsp;g_msg.substring(0, g_pos++);<br>&nbsp;&nbsp;if ( g_pos &lt;= g_msg.length)<br>&nbsp;&nbsp;&nbsp;&nbsp;setTimer();<br>}<br><br>function setTimer(){<br>&nbsp;&nbsp;window.setTimeout(&quot;displayNextMsg()&quot;, 500);<br>}<br>//--&gt;<br>&lt;/script&gt;<br>&lt;/HEAD&gt;<br>&lt;BODY onload=&quot;setTimer()&quot;&gt;<br>&lt;div id=&quot;msgDisplay&quot;&gt; &lt;/div&gt;<br><br><br>Have fun<br>-pete
 
<br>&lt;div id=&quot;msgDisplay&quot; style=&quot;font-face: Arial;&quot;&gt; &lt;/div&gt;<br><br>or<br><br>&lt;style type=&quot;text/css&quot;&gt;<br>&lt;!--<br>.mymsg{<br>&nbsp;&nbsp;font-family: Arial;<br>&nbsp;&nbsp;font-size: 18px;<br>&nbsp;&nbsp;color: #00ff99;<br>}<br>--&gt;<br>&lt;/style&gt;<br><br>&lt;div id=&quot;msgDisplay&quot; class=&quot;mymsg&quot;&gt; &lt;/div&gt;<br><br>-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top