>
 





Time delay in url redirection may be useful for the following conditions:


The html and JavaScript code for url redirection with delay is given below:

<html>
<head>
<script type="text/javascript">
function delayedRedirect(){
    window.location = "/default.aspx"
}
</script>
</head>
<body onLoad="setTimeout('delayedRedirect()', 3000)">
<h2>You'll be redirected soon!</h2>
</body>
</html>

The JavaScript function setTimeout is the most important part of the code given above. setTimeout function calls delayedRedirect function after 3 seconds (3000 miliseconds).

You may find the details of setTimeout() method in JavaScript setTimeout Function - JavaScript Timing Events

Want automatic updates? Subscribe to our RSS feed or
Get Email Updates sent directly to your inbox!

Currently rated 4.3 by 4 people

  • Currently 4.25/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Comments

November 19. 2007 19:09

hi.  what do you think of using the http meta tag to do the refresh?
of course setTImeout is more fine grained.

j to | Reply

November 21. 2007 05:20


For both scenarios (refreshing a page at a specified interval and redirecting), using the META tag is the better way to do this - if a browser has JavaScript turned off you will still get the desired effect with the META tag.

Jason Bunting | Reply

December 21. 2007 06:03

thanks, very usefull

jack | Reply

October 27. 2009 14:26

Hmmm interesting stuff

cash loans | Reply

Add comment




(Will not be displayed!)