I have a javascript function that runs every one minute.
setInterval(function(){
//first, check time, if it is 9 AM, reload the page
var now = new Date();
if (now.getHours() == 9 {
window.refresh();
}
//do other stuff
},60000);
Now the problem is, I want the reload to happen only once a day. since the function runs every minutes, so next time it fires up, it will reload the page again if it is between 9AM and 10AM. How do I make the reload happen only once?
I can probably do it by creating another interval function that fires every hour and check if I should reload. but since I already have the above function that runs every minute, can I do it from there?
If I do end up with creating another function that checks every hour. What will happen if those 2 functions fire up at the exact same time?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…