Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirection after a time

Status
Not open for further replies.

Maldini

Technical User
Nov 10, 2002
55
0
0
GB
Hi,

I've been trying to get a simple javascript redirection fucntion to work, after this form in ASP has been posted back. Once checked to be valid, I'm showing some hidden divs to the user and want to redirection in say 10 seconds.

I can do the redirection part using:
window.location
in javascript, but I don't seem to be able to get the timed effect. Been googling, but with setTimeOut, it only seems to work on a fresh load of the page and isn't for this instance.

Anyone happen to have any examples or hints?

Thanks.
Maldini
 
Using "setTimeOut" would get you nothing but errors, as JS is case-sensitive. Use "setTimeout" instead:

Code:
setTimeout('window.location = \'[URL unfurl="true"]http://www.google.co.uk\';',[/URL] 10000);

That should redirecct you after 10 seconds, assuming you do not navigate away from the page that instigated it, of cousre.

Hope this helps,
Dan


The answers you get are only as good as the information you give!
 
Hi,
Thanks for the reply.
I notice the way you've encapsulated the string with quotes. Is this for the body onLoad statement?

I'm not sure if this would work in my instance, as I'm posting back to the same page and processing on it, then deciding to redirect if correct.

Thanks again.

Maldini
 
Got it, used the setTimeout to call another function after the time limit, does the job. Thanks.
 

I notice the way you've encapsulated the string with quotes. Is this for the body onLoad statement?

No - the first parameter to setTimeout must always be a string, regardless of where you call it from.

Dan


The answers you get are only as good as the information you give!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top