Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
JavaScript - Timer && Execute
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Lulzie" data-source="post: 411053" data-attributes="member: 76015"><p>Got this code, it won't run I keep getting errors in the chrome console. Need helps, Cheers</p><p></p><p>[code]</p><p>function checkTimeAndLoad(){</p><p> var date = new Date();</p><p> var currentHour = date.getHours();</p><p> var currentMinutes = date.getMinutes();</p><p> var currentSeconds = date.getSeconds();</p><p> </p><p> var hourRefresh = 22;</p><p> var minuteRefresh = 55;</p><p> </p><p> while (true){</p><p> if (currentHour != hourRefresh){</p><p> sleep(60 * 1000 - (currentSeconds)); #wait the seconds left in the minute</p><p> sleep(60*1000*60-(currentMinutes-1); #wait the minutes left in the hour</p><p> var date = new Date();</p><p> currentHour = date.getHours(); #get the new hour</p><p> currentSeconds = date.getSeconds();</p><p> </p><p> }else if (currentMinutes != minuteRefresh){</p><p> sleep(60 * 1000 - (currentSeconds)); #wait the seconds left in the minute</p><p> sleep(60*1000*60-(currentMinutes-1); #wait the minutes left in the hour</p><p> var date = new Date();</p><p> currentMinutes = date.getMinutes();</p><p> currentSeconds = date.getSeconds();</p><p> </p><p> }else{</p><p> break;</p><p> }</p><p> window.location.href = (url)</p><p> </p><p> </p><p> }</p><p> }</p><p> </p><p>checkTimeandLoad();</p><p></p><p>[/code]</p><p>[doublepost=1496633227,1496631158][/doublepost]Fixed a few errors but it still runs wobbly... ;/</p><p></p><p>[code]</p><p>function checkTimeAndRefresh(){</p><p> var date = new Date();</p><p> var currentHour = date.getHours();</p><p> var currentMinutes = date.getMinutes();</p><p> var currentSeconds = date.getSeconds();</p><p> </p><p> var hourRefresh = 23;</p><p> var minuteRefresh = 18;</p><p> </p><p> while (true){</p><p> if (currentHour != hourRefresh){</p><p> setTimeout(60 * 1000 - (currentSeconds));</p><p> setTimeout(60*1000*60-(currentMinutes-1));</p><p> var date = new Date();</p><p> currentHour = date.getHours();</p><p> currentSeconds = date.getSeconds();</p><p> </p><p> }else if (currentMinutes != minuteRefresh){</p><p> setTimeout(60 * 1000 - (currentSeconds));</p><p> setTimeout(60*1000*60-(currentMinutes-1));</p><p> var date = new Date();</p><p> currentMinutes = date.getMinutes();</p><p> currentSeconds = date.getSeconds();</p><p> </p><p> }else{</p><p> break;</p><p> }</p><p> window.location.href = url</p><p> </p><p> </p><p> }</p><p> }</p><p> </p><p>checkTimeAndLoad();[/code]</p></blockquote><p></p>
[QUOTE="Lulzie, post: 411053, member: 76015"] Got this code, it won't run I keep getting errors in the chrome console. Need helps, Cheers [code] function checkTimeAndLoad(){ var date = new Date(); var currentHour = date.getHours(); var currentMinutes = date.getMinutes(); var currentSeconds = date.getSeconds(); var hourRefresh = 22; var minuteRefresh = 55; while (true){ if (currentHour != hourRefresh){ sleep(60 * 1000 - (currentSeconds)); #wait the seconds left in the minute sleep(60*1000*60-(currentMinutes-1); #wait the minutes left in the hour var date = new Date(); currentHour = date.getHours(); #get the new hour currentSeconds = date.getSeconds(); }else if (currentMinutes != minuteRefresh){ sleep(60 * 1000 - (currentSeconds)); #wait the seconds left in the minute sleep(60*1000*60-(currentMinutes-1); #wait the minutes left in the hour var date = new Date(); currentMinutes = date.getMinutes(); currentSeconds = date.getSeconds(); }else{ break; } window.location.href = (url) } } checkTimeandLoad(); [/code] [doublepost=1496633227,1496631158][/doublepost]Fixed a few errors but it still runs wobbly... ;/ [code] function checkTimeAndRefresh(){ var date = new Date(); var currentHour = date.getHours(); var currentMinutes = date.getMinutes(); var currentSeconds = date.getSeconds(); var hourRefresh = 23; var minuteRefresh = 18; while (true){ if (currentHour != hourRefresh){ setTimeout(60 * 1000 - (currentSeconds)); setTimeout(60*1000*60-(currentMinutes-1)); var date = new Date(); currentHour = date.getHours(); currentSeconds = date.getSeconds(); }else if (currentMinutes != minuteRefresh){ setTimeout(60 * 1000 - (currentSeconds)); setTimeout(60*1000*60-(currentMinutes-1)); var date = new Date(); currentMinutes = date.getMinutes(); currentSeconds = date.getSeconds(); }else{ break; } window.location.href = url } } checkTimeAndLoad();[/code] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
JavaScript - Timer && Execute
Top