I’m trying to re-direct to another page if a web page visitor leaves the page displayed after X amount of time with no activity. I’ve tried this with no redirect. What am I missing?
<script type="text/javascript">
(function() {
const idleDurationSecs = 60; // X number of seconds
const redirectUrl = 'https://......com'; // Redirect idle users to this URL
let idleTimeout; // variable to hold the timeout, do not modify
const resetIdleTimeout = function() {
// Clears the existing timeout
if(idleTimeout) clearTimeout(idleTimeout);
idleTimeout = setTimeout(() => location.href = redirectUrl, idleDurationSecs * 1000);
};
// Init on page load
resetIdleTimeout();
// Reset the idle timeout on any of the events listed below
['click', 'touchstart', 'mousemove'].forEach(evt =>
document.addEventListener(evt, resetIdleTimeout, false)
);
})();
</script>
Surprisingly almost 18% so that is why I try to still code with it. I would like to steer users to just use Edge, Chrome and FF. Can’t seem to find - is there reliable JS that won’t allow users to open pages that displays message that IE is not supported?