Timer to Redirect Users To Another Webform!

 In this blog post, we will discuss how to create a decremental timer which will redirect the user to another page after 60 seconds. You might have seen this feature in almost every site providing content to be downloaded.

Below is Javascript code to be inserted inside the <head> tag of the HTML.

    <script language="javascript">
    // Set timer to 60 seconds which will redirect the user to WEbForm1.
    window.setTimeout('window.location.href=\"WebForm1.aspx\"',60000);
    function Timer()
    {   
        // Call the UpdateLabel Function each second to show the decremental timer to the user
        window.setTimeout('UpdateLabel()',1000);
    }
    function UpdateLabel()
    {
         // Get the label object
         var label = document.getElementById('<%=Label1.ClientID %>');
         // Decrease the label value by 1
         label.innerHTML = parseInt(label.innerHTML) - parseInt('1');
         // Recall this function every 1 seconds.
          window.setTimeout('UpdateLabel()',1000);
    }
    </script>

For Making this sample work, insert a label with id Label1 and text equals to 60.

 

Hope this Helps,

 

 

Published 03 December 2007 08:41 PM by haissam

Comments

No Comments

This site

Search

Go

This Blog

Syndication

Sponsors

  • MaximumASP
  • Breaking News
  • Find a Job
  • Social Bookmarking
    Tidebuy Reviews
    Online Shopping
    asp.net hosting
    UK online local dating