倒数计时器后重定向到另一页

时间:2019-12-16 20:37:13

标签: html

我有一个倒数计时器模板引导程序 即时通讯设置新的一年的计时器,但我想在时间结束后将页面自动重定向到我网站上的另一个页面 这是我的js

 $(window).load(function(){
     $('.preloader').fadeOut('slow');
});


function initializeSite() {

    "use strict";


    (function() {
        function centerInit(){

            var sphereContent = $('.sphere'),
                sphereHeight = sphereContent.height(),
                parentHeight = $(window).height(),
                topMargin = (parentHeight - sphereHeight) / 2;

            sphereContent.css({
                "margin-top" : topMargin+"px"
            });

            var heroContent = $('.hero'),
                heroHeight = heroContent.height(),
                heroTopMargin = (parentHeight - heroHeight) / 2;

            heroContent.css({
                "margin-top" : heroTopMargin+"px"
            });

        }

        $(document).ready(centerInit);
        $(window).resize(centerInit);
    })();


    $('#scene').parallax();

};

$(window).load(function(){

    initializeSite();
    (function() {
        setTimeout(function(){window.scrollTo(0,0);},0);
    })();

});



$('#countdown').countdown({
    date: "January 1, 2020 00:00:00",
    render: function(data) {
      var el = $(this.el);
      el.empty()

        //.append("<div>" + this.leadingZeros(data.years, 4) + "<span>years</span></div>")
        .append("<div>" + this.leadingZeros(data.days, 2) + " <span>ДНЕЙ</span></div>")
        .append("<div>" + this.leadingZeros(data.hours, 2) + " <span>ЧАСЫ</span></div>")
        .append("<div>" + this.leadingZeros(data.min, 2) + " <span>МИНУТ</span></div>")
        .append("<div>" + this.leadingZeros(data.sec, 2) + " <span>СЕКУНД</span></div>");
    }
});

我尝试添加

if (seconds < 0) {
            // Chnage your redirection link here
            window.location = "#";
        }

但是倒计时在此代码后消失 任何帮助,将不胜感激 *我是新编码员,所以如果解决方法很简单,请问我))

1 个答案:

答案 0 :(得分:0)

假设其余部分正确无误...更改:

if (seconds < 0) {
   // Chnage your redirection link here
   window.location = "#";
}

if (seconds < 0) {
   //put the page name below (index.html is common, but not for sure. You would know)
   window.location.href = "index.html"; 
}