aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

JavaScript Redirect to Another Page After 5 seconds or Some Time Delay in

Oct 14, 2012

Here I will explain how to redirect to another page after 5 seconds or some time delay in

In previous articles I explained
JQuery display Current Time on WebPage, JavaScript display current time on webpage, Disable right click on image and many articles relating to JQuery and JavaScript. Now I will explain how to redirect to another page after 5 seconds or some time delay in JavaScript.

To implement this functionality we need to write the following code

<html xmlns="">
<head id="Head1" runat="server">
<title>JavaScript redirect to another page after 5 seconds or Sometime</title>
<script type="text/javascript">
var i = 0;
function ShowCurrentTime() {
var dt = new Date();
document.getElementById("lblTime").innerHTML = 5 - i + " Seconds";
if (i == 5) {
setTimeout("location.href=''", 0);
window.setTimeout("ShowCurrentTime()", 1000); // Here 1000(milliseconds) means 1 sec
<body onload="ShowCurrentTime()">
<form id="form1" runat="server">
<h3>Redirect to Another page Example</h3>
This Page will Redirect to Another Page within:
<label id="lblTime" style=" font-weight:bold; font-size:x-large"></label>

Live Demo

Click Button to Redirect:

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


Aswini said...


Thank you for this code and i have a doubt about this code in location will we use localhost means it getting an error

Suresh Dasari said...

Please check the url whatever you given it will work anywhere

Anonymous said...

Thank You very Much sir. This site is very helpful for student like me.

Thanks a lots

Anonymous said...

hello sir, it is not getting redirect....please help me

Anonymous said...

sir what is the use of first script is this essential to write it.....

Suresh Dasari said...

that script file not necessary i updated the post u can check it. This one working fine if you want to check it click on the button in demo section. I hope u did mistake in your code. check it

Anonymous said...

thank u so much for ur quick response u are doing gud job......ankit

Anonymous said...

function Delayer()
setTimeout('Redirection()', 10000);
function Redirection()

this is my code...will u please check this sir is this correct....ankit

Anonymous said...

actually running time was not showing in label when i was trying ur code....thats y i edited that code.....ankit

Unknown said...

How to use this technics in master page

Anonymous said...

There is no button mentioned in your code but I could see button in your demo page. Can you explain that process?

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.