var now = new Date(), end = new Date("2014/12/16 10:00"); if(now > end){ var html = ‘<div id="mbox_overlay" class="mbox_overlay"></div>‘+ ‘<div class="pop-box">‘+ ‘<p>很遗憾,活动已经结束啦</p>‘+ ‘<p class="J_end"></p>‘+ ‘ </div>‘; var t=3;//设定跳转的时间 var refer = function(){ if(t==0){ location="http://www.xxx.com"; //#设定跳转的链接地址 } $(‘.J_end‘).html("" + t + "秒后为您跳转至首页"); // 显示倒计时 t--; }; setInterval(refer,1000);//启动1秒定时 $(‘body‘).append(html); }else{};
原文:http://www.cnblogs.com/shupiankele/p/4167875.html