Auto redirect page using javascript

By
Advertisement

Introduction:
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.

Explanation:
To auto redirect the page after 5 seconds to google.co.in the below code is used.

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

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

    </script>
    <a href="JavaScript:void(0);" onclick="JavaScript:timedRedirect(redirectTo='http://www.google.co.in',timeoutPeriod='2000')">
    Redirect in 5 seconds...</a>
</div>
</form>

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.

0 comments:

Post a Comment

Online Casino