I want a website to refresh every 1 second, but I also want the javascript codes above the setTimeout function to execute first before the setTimeout function executes. If I put the setTimeout function below the codes, does it mean that it will only execute the setTimeout function once the codes above are executed?
//long code that i want executed before the setTimeout executes.
var timeout = setTimeout("location.reload(true);",1000);
function resetTimeout() {
clearTimeout(timeout);
timeout = setTimeout("location.reload(true);",1000);
}
So basically I want this to happen. The codes above executes. Then and only then will the setTimeout function execute - pausing for a second before refreshing the website.