setInterval(function(){
var d=new date()
if(d.getFullYear()==2018&&d.getMonth()==0&&d.getDate()==27&&d.getHours()==18&&d.getMinutes()==0)
location.reload()
},60000)
</script>
以上代码只会在指定时间(2018-1-27 18:00:00)刷新一次,如果希望每天的同一时间(比如18点整)都刷新,则
<script>setInterval(function(){
var d=new date()
if(d.getHours()==18&&d.getMinutes()==0)
location.reload()
},60000)
</script>
var timeTask=setInterval(function(){var date=new Date()
var h=date.getHours()
var m=date.getMinutes()
var s=date.getSeconds()
if(h==12&&m==0&&s==0){
callFunction()
}
},1000)
function callFunction(){
alert(1)
}
这样, 就可以了。
var date = new Date()var hour = date.getHours()
if(hour<4){//0~3:59:59
location.href='/a'
}else if(hour>4){5~23:59:59
location.href='/b'
}else{//4~4:59:59
var second = date.getSeconds()
var minute = date.getMinutes()
if(second + minute === 0){//4:0:0
location.href='/a'
}else{//4点其他时间
location.href='/b'
}
}