Falaileh
Falaileh

Reputation: 1

How to load page after countdown finished in javascript

I have this code :

<h1 id="countdown-holder"></h1> 
<script>  
    var clock = document.getElementById("countdown-holder")  
    , targetDate = new Date(2050, 00, 01); // Jan 1, 2050;  

    clock.innerHTML = countdown(targetDate).toString();  
    setInterval(function(){  
        clock.innerHTML = countdown(targetDate).toString();  
    }, 1000);  
</script>  

How can i load page after countdown finish ??

Upvotes: 0

Views: 283

Answers (2)

Paul Rumkin
Paul Rumkin

Reputation: 6873

This is exact what you need

var now = Date.now();
if (now >= targetDate) {
    window.location = './target/url';
}

Upvotes: 1

Gaurav
Gaurav

Reputation: 1294

Since you have not described your "countdown" function here, we can assume that you can match when the countdown finish. Use the following code when your countdown finish:

window.location.replace("Page URL");

Upvotes: 0

Related Questions