Javascript 完成后重定向的倒计时计时器

Javascript 完成后重定向的倒计时计时器,javascript,redirect,countdown,Javascript,Redirect,Countdown,我一直在尝试为特定时间和日期(即2013年6月17日格林尼治标准时间上午9点)的倒计时计时器寻找脚本(最好是JavaScript)。当倒计时完成时(即6月17日格林尼治标准时间上午9点之后),我希望该站点开始自动重定向到另一个页面。我实际上为我们与同事举行局域网聚会时编写了一个简单的倒计时脚本:-) 我没有花时间让它成为jQuery插件,它有一个奇怪的结构,但它可以工作,你可以根据自己的需要修改它 你试过什么?对于这个简单的任务,网上有很多解决方案。太棒了!非常感谢你!但是有一个问题(对不起,

我一直在尝试为特定时间和日期(即2013年6月17日格林尼治标准时间上午9点)的倒计时计时器寻找脚本(最好是JavaScript)。当倒计时完成时(即6月17日格林尼治标准时间上午9点之后),我希望该站点开始自动重定向到另一个页面。

我实际上为我们与同事举行局域网聚会时编写了一个简单的倒计时脚本:-)

我没有花时间让它成为jQuery插件,它有一个奇怪的结构,但它可以工作,你可以根据自己的需要修改它


你试过什么?对于这个简单的任务,网上有很多解决方案。太棒了!非常感谢你!但是有一个问题(对不起,我是新手),我应该在哪里编辑以输入我希望在倒计时结束时重定向到的页面地址?还有,这个倒计时设置为特定的时区吗?我原来的倒计时没有重定向功能。但是,如果您查看一下
updateTime
函数,我添加了一个文本
newurl..
,这就是url所在的位置,您还可以将其作为一个参数。此倒计时功能仅使用用户进入页面的时区。因此,如果您需要对此进行说明,您需要让服务器编写当前日期和时间,并让脚本对此进行说明。太好了,非常感谢您。我真的很感谢你的帮助
(function($, undefined) {
    countdown = function(settings) {
        var _this = this,
            defaults = {
                end: '30.09.2012 09:00'
            }, rDate = /(\d+).(\d+).(\d+) (\d+):(\d+)/;

        _this.settings = $.extend(defaults, settings);

        var matches = _this.settings.end.match(rDate);

        _this.endDate = new Date(matches[3], matches[2] - 1, matches[1], matches[4], matches[5], 0, 0);

        _this.nDays = $('<span />').addClass('countdown days').html('0');
        _this.nHours = $('<span />').addClass('countdown hours').html('0');
        _this.nMinutes = $('<span />').addClass('countdown minutes').html('0');
        _this.nSeconds = $('<span />').addClass('countdown seconds').html('0');

        _this.settings.element.append(
            $('<span />').append(
                _this.nDays,
                ' Days'
            ),
            $('<span />').append(
                _this.nHours,
                ' Hours'
            ),
            $('<span />').append(
                _this.nMinutes,
                ' Minutes'
            ),
            $('<span />').append(
                _this.nSeconds,
                ' Seconds'
            )
        );

        countdownMethods.start.call(_this);

        return _this;
    };

    var countdownMethods = {
        start: function() {
            var _this = this,
                interval = 0;

            var updateTime = function() {
                var now = new Date(),
                    diff = Math.round((_this.endDate - now) / 1000);

                if(diff < 0) {
                    diff = 0;
                    clearInterval(interval);
                    window.location.href = 'newurl..';
                }

                var days = Math.floor(diff/86400);

                diff -= days * 86400;

                var hours = Math.floor(diff/3600);
                diff -= hours * 3600;

                var minutes = Math.floor(diff/60);
                diff -= minutes * 60;

                _this.nDays.html(days);
                _this.nHours.html(hours);
                _this.nMinutes.html(minutes);
                _this.nSeconds.html(diff);
            };

            updateTime();

            interval = setInterval(function() {
                updateTime();
            }, 1000);
        }
    };
})(jQuery);
$(function() {
    var counter = countdown({
        end: '08.05.2013 15:15',
        element: $('div')
    });
});