Created
December 2, 2019 21:17
-
-
Save lusbuab/e6c87aa1f6a97121ce8ec9e8c8bcd8b1 to your computer and use it in GitHub Desktop.
Refresh the page if it was inactive for too long.
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
;(function(refreshAfter){ | |
var hideTime = null | |
document.addEventListener("visibilitychange", function() { | |
if (document.hidden) { | |
hideTime = Date.now() | |
} else if (hideTime && Date.now() - hideTime > refreshAfter) { | |
location.reload() | |
} | |
}, false) | |
}(5000)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment