CountDown with changing content of the index

Forum for all related to Javascript
Post Reply
User avatar
Kosmito
Site Admin
Posts: 17
Joined: Mon Jan 09, 2023 7:16 pm
Contact:

CountDown with changing content of the index

Post by Kosmito »

This Script was create for launch pages

Code: Select all

<script>
                                var countDownDate = new Date("Sept 29, 2022 3:00:00").getTime();
                                var x = setInterval(function() {
                                    var now = new Date().getTime();
                                    var distance = countDownDate - now;
                                    var days = Math.floor(distance / (1000 * 60 * 60 * 24));
                                    var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
                                    var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
                                    var seconds = Math.floor((distance % (1000 * 60)) / 1000);
                                    document.getElementById("countdown").innerHTML = days + " Days " + hours + " Hours " +
                                        minutes + " Minutes " + seconds + " Seconds ";
                                    if (distance < 0) {
                                        clearInterval(x);
                                        document.querySelector("#div1").style.display = "block";
                                        document.getElementById("demo").style.visibility = "hidden";
                                    }
                                }, 1000);
                            </script>
With this you can show the countdown and other message you like

Code: Select all

<div id="demo" class="main-wrap rounded-border-window">
           We show the countdown with 
 <div id="countdown"></div>
        </div>
When the countdown finish and they load this page

Code: Select all

        <div class="main-wrap rounded-border-window" id="div1" style="display:none;">
CountDown Finish now they show the page 
</div>
Image
Image
Post Reply