>
 





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. Javascript setTimeout function calls delayedRedirect function after 3 seconds (3000 miliseconds).

You may find more 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 5.0 by 3 people

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


Comments

October 23. 2009 02:22

Social comments and analytics for this post

This post was mentioned on Twitter by bloggingdev: Javascript Delayed Redirect - http://su.pr/84JsUn

uberVU - social comments | Reply

October 24. 2009 23:43

I think, this is not a good idea.

Alexsandro | Reply

October 27. 2009 12:21

Why not use anonymous functions?

<body onload="window.setTimeout(function() {window.location = "/default.aspx"}, 3000)">

Anton | Reply

October 28. 2009 22:04

Merci pour l'article !!!

oziks | Reply

November 6. 2009 04:19

Perhaps it becomes the first time I visit your blog, yet I know it contains so many useful things here. thanks a lot.

kerja keras | Reply

November 23. 2009 13:46

So far, I managed to go though only some of posts you discuss here, but I find them very interesting and informative. Just want say thank you for the information you have shared. Regards

web messenger software | Reply

December 19. 2009 12:53

Thank you for this! Quite useful!

iMatt | Reply

Add comment




(Will not be displayed!)