我将代码修改成了下面,当倒计时为0 时调用Wopen()这个函数打开一个新网址。但每次倒计时结束后总是无法打开
curShowTimeSeconds = getCurrentShowTimeSeconds()
if(curShowTimeSeconds == 0 ){
Wopen();
}else{
setInterval(
function(){
render( context );
update();
}
,
50
);}
}
function Wopen() {
window.open('http://www.imooc.com','_blank')
}function getCurrentShowTimeSeconds() {
var curTime = new Date();
var ret = endTime.getTime() - curTime.getTime();
ret = Math.round( ret/1000 )
if(ret==0)
Wopen();
return ret >= 0 ? ret : 0;
}把判断放到getCurrentShowTimeSeconds()里面即可!