Docthorn

Question.

Is it possible to delay the execution of a

javascript

  script?
For example I open somesite/page1 and after 5 seconds the page executes some

javascript

 .

If not, can I get around this with a

PHP

  page that after five seconds loads a frame, and inside the frame the page with the

javascript

  code? I'm brainstorming a bit to find possible solutions so forgive me if what I said makes no sense.

Ciao,
Doc

perkiset

Very simple:

setTimeout('theFunctionYouWantToCall()', 5000);

This would do exactly what you are trying to accomplish, provided the function had your redirect code...

function theFunctionYoWantToCall()
{
top.lcation='http://www.spamsite.com';
}

You may also put pure code right in there:

setTimeout("top.location='http://www.thespamsite.com'", 5000);

/p

Docthorn

Great. Simpler than I tought, thank you perkiset.

Doc

perkiset

No worries.

Since we're at it, there is another handy function along these same lines: setInterval(jsCode, intervalMS) which does the same as setTimeout except that it does it repeatedly at intervalMS. Excellent for beacons and such.

/p


Perkiset's Place Home   Politics @ Perkiset's