Related Posts Plugin for WordPress, Blogger...

About

Follow Us

Saturday, 25 July 2015

Introduction:

In this article I will explain how to redirect to other page after some time, ex. 5 seconds.  This can be done by using javascript or jquery.

In this article I will use JavaScript to redirect to   other page with delay.

Full Source Code For Redirect after 5 seconds:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
    <fieldset style="width:400px;"><legend><strong>Redirect to other Page After 5 Second Using Jquery</strong></legend>
      <br />  Click here to redirect Page&nbsp;&nbsp;&nbsp;
<input type="button" value="Redirect" onclick="DelayRedirect()" />
<br />
<br />
<div id="dvCountDown" style = "display:none">
You will be redirected after <span id = "lblCount"></span>&nbsp;seconds.
</div></fieldset>
<script type="text/javascript">
    function DelayRedirect() {
        var seconds = 5;
        var dvCountDown = document.getElementById("dvCountDown");
        var lblCount = document.getElementById("lblCount");
        dvCountDown.style.display = "block";
        lblCount.innerHTML = seconds;
        setInterval(function () {
            seconds--;
            lblCount.innerHTML = seconds;
            if (seconds == 0) {
                dvCountDown.style.display = "none";
                window.location = "http://www.maziksolutions.com/";
            }
        }, 1000);
    }
</script>
</body>

</html>

0 comments:

Post a Comment