Jump to content

[SOLVED] Pause/Stop/Break


daveoffy

Recommended Posts

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();
}

Link to comment
https://forums.phpfreaks.com/topic/140091-solved-pausestopbreak/
Share on other sites

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');">

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.