daveoffy Posted January 8, 2009 Share Posted January 8, 2009 I need to stop the text from looping. Code is below. TY var text='TEXT IS HERE'; var delay=100; var currentChar=1; var destination="[none]"; function type() { //if (document.all) { var dest=document.getElementById(destination); if (dest)// && dest.innerHTML) { dest.innerHTML=text.substr(0, currentChar)+"_"; currentChar++; if (currentChar>text.length) { currentChar=1; setTimeout("type()", 5000); } else { setTimeout("type()", delay); } } } } function startTyping(textParam, delayParam, destinationParam) { text=textParam; delay=delayParam; currentChar=1; destination=destinationParam; type(); } Quote Link to comment Share on other sites More sharing options...
Lautarox Posted January 9, 2009 Share Posted January 9, 2009 Where's the loop there? Quote Link to comment Share on other sites More sharing options...
daveoffy Posted January 9, 2009 Author Share Posted January 9, 2009 I don't know but it loops the text. Maybe this code will help javascript:startTyping(text, 100, "textDestination"); That is on the bottom Quote Link to comment Share on other sites More sharing options...
Lautarox Posted January 9, 2009 Share Posted January 9, 2009 Do you need this done after an event? I don't really know why is it looping, assign an event to call your function, it should be called once Quote Link to comment Share on other sites More sharing options...
daveoffy Posted January 9, 2009 Author Share Posted January 9, 2009 I don't know javascript! I found this on a website. Quote Link to comment Share on other sites More sharing options...
Lautarox Posted January 9, 2009 Share Posted January 9, 2009 Mmm.. well.. First of all var dest=document.getElementById(destination);, destination isn't declared in that function pass it as argument in the type function, function type(destination) { ... and when you call it destination=destinationParam; type(destination); , now you might want to call this function on a button click or something like that, if you want a button you could write something like this <input type="submit" value="Call Function" onclick="startTyping('text you want, if you want', 100, 'textDestination');"> Quote Link to comment Share on other sites More sharing options...
daveoffy Posted January 9, 2009 Author Share Posted January 9, 2009 I don't want it off a button. I want it to go right when the page loads and want it to only show the text once and not clear it out and re type it. Quote Link to comment Share on other sites More sharing options...
Lautarox Posted January 9, 2009 Share Posted January 9, 2009 You can use an onload event, check this pages http://www.w3schools.com/jsref/jsref_events.asp http://www.w3schools.com/JS/js_events.asp Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.