Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Web
Expertise: Intermediate
Jul 12, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Redirecting to Another URL with setTimeout

Most of Web developers may be familiar with the META REFRESH tag in HTML. This tag is used to take the user to another location automatically, after a specified delay. In the example given below, the browser automatically navigates to 'newpage.html', 5 seconds after the page is loaded.


In some cases, however, you might want to take the user to another page, perhaps depending on some actions and a varying time delay. In this context the META REFRESH tag cannot be used because it is dependent on the time when the page was loaded. The following JavaScript code snippet helps to achieve this feature using the setTimeout function.

setTimeout('window.location.href="newpage.html"', 10000); 
This statement, when called during the specific event or action, navigates the user automatically to "newpage.html" after a delay of 10 secs (10000 milliseconds).

Ajith Prasad
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date