js.
js.

Reputation: 1

Simple Javascript function onload

Here I have a function

function photoLoop() {
fade1L('3000');fade1M('3500');fade1R('4000');show2L('3000');show2M('3500');show2R('4000');
}

When the page loads this function is called <body onload="photoLoop();>

At this point these functions are run until it reaches the end i.e show2R('4000');

My problem is I want it to now go back to fade1L('3000'); and start over.

How can this be done, with out crashing IE?

Upvotes: 0

Views: 88

Answers (3)

Luke Bennett
Luke Bennett

Reputation: 32896

Instead of calling the function directly, do the following which will repeat the function at the specified interval:

setInterval(photoLoop, 1000);

Where 1000 is the interval to repeat the function in milliseconds. You will presumably want to set this to the total duration of these animations (21000ms at a guess).

Upvotes: 0

John Polling
John Polling

Reputation: 2282

Use the jQuery Effects library and make use of the 'callback' functionality

e.g. http://docs.jquery.com/Effects/fadeIn

Upvotes: 2

Vijay Dev
Vijay Dev

Reputation: 27466

Use setTimeout().

You can do

setTimeout(photoLoop, 1000); // call the function after 1 second.

Upvotes: 0

Related Questions