function refresh(milliseconds) { console.log("Refreshing"); setTimeout("location.reload(true);", milliseconds); } function your_code() { //code stuff refresh(1000); //refreshes after 1 second }