function Countdown(time) {
var _this = this;
(function(){
document.getElementById('test').innerText = time-- + '秒';
_this.timeFunc = setTimeout(arguments.callee, 1000);
})();
setInterval(function() {
clearTimeout(_this.timeFunc);
clearInterval(arguments.callee);
window.location.href = 'http://www.baidu.com';
}, parseInt((time+1))*1000);
}
Countdown(5);
大家看下上面的这段js代码,实现的效果就是指定时间后跳转到一个指定的地址,这里有两点疑问:
我需要在跳转前clear掉两个定时吗?
代码中有什么不妥的地方吗?比如那个 _this
?
希望各位朋友能给点建议哈。
aluckdog
相关分类