Click to See Complete Forum and Search --> : How do I a 'GoTo' ?


Javium
11-11-2003, 07:28 PM
Hello everybody

In old Basic we can use the simple directive GOTO to go back to a precise point in the program.

In JavaScript, I would like to go back to a point in the .htm file, after having done a setTimeout('xxx()', n)
Is this possible? My goal is to make a slideshow with an array containing the images names and a counter for pointing the image from the array.

Many Thanks in advance.
Javium

leighhalliday
11-11-2003, 11:14 PM
I am not too sure about a GoTo.... I thought they were now considered bad programming practise?

But this may be of help...
In head...

var runner = new Array(6);
var curRunner = 0;
var startRunning;

runner[0] = "runner0.jpg";
runner[1] = "runner1.jpg";
runner[2] = "runner2.jpg";
runner[3] = "runner3.jpg";
runner[4] = "runner4.jpg";
runner[5] = "runner5.jpg";

function marathon() {
if (curRunner == 5)
curRunner = 0;
else
++curRunner;
document.animation.src = runner[curRunner];
}

In body....

<img src="runner0.jpg" name="animation">
<form>
<input type="button" name="run" value=" run " onclick="startRunning=setInterval('marathon()', 100);">
<input type="button" name"stop" value=" stop " onclick="clearOnterval(startRunning);">
</form>


So...

You refer to the source of an image in your javascript which will cycle through the images in an array at an interval of 100

Hope this was some help, if you could help me I posted one called "changing text onClick()"

Leigh