Last active
August 27, 2018 14:15
-
-
Save carlessanagustin/a4a8b748186281a3d1fe to your computer and use it in GitHub Desktop.
(Javascript) Auto refresh checkbox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- add Javascript in html head --> | |
<script> | |
var reloading; | |
var refresh_time = 30000; | |
function checkReloading() { | |
if (window.location.hash=="#autoreload") { | |
reloading=setTimeout("window.location.reload();", refresh_time); | |
document.getElementById("reloadCB").checked=true; | |
} | |
} | |
function toggleAutoRefresh(cb) { | |
if (cb.checked) { | |
window.location.replace("#autoreload"); | |
reloading=setTimeout("window.location.reload();", refresh_time); | |
} else { | |
window.location.replace("#"); | |
clearTimeout(reloading); | |
} | |
} | |
window.onload=checkReloading; | |
</script> | |
<!-- add input checkbox in html body --> | |
<span><input type="checkbox" onclick="toggleAutoRefresh(this);" id="reloadCB"> Auto Refresh</span> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This no longer works in Chrome or Firefox. Still works in IE. Used to work in all three.