Auto redirect page using javascript


In my previous article I have explained about  how to Create or reset the identity value of a column in sql server. In this article I am going to explain about how to auto redirect page after some time delay using javascript.

To auto redirect the page after 5 seconds to the below code is used.

<form id="form1" runat="server">
    <script type="text/JavaScript">

        function timedRedirect(redirectTo, timeoutPeriod) {
            setTimeout("location.href = redirectTo;", timeoutPeriod);

    <a href="JavaScript:void(0);" onclick="JavaScript:timedRedirect(redirectTo='',timeoutPeriod='2000')">
    Redirect in 5 seconds...</a>

In the above code instead of calling the tiledRedirect function in onclick event if you call it in window.onload then the page will get redirected automatically after 5 seconds..

Do you like this article. Help us to improve.Post your comments below.


Post a Comment

Online Casino