I have the code below that works for the most part, but I wonder if it can be tweaked a bit. So what the following code does, if they are not mouse activity for x milliseconds, a pop-up window is displayed saying that they will be logged out, and then when / if you end up clicking the ok button, the script will automatically lead you to the exit file.
However, I would like to do this if the ok button is not pressed after x is the number of milliseconds to continue and bring the screen to the logout.php file. Does anyone know how I can do this using the code below? Thanks
// Set timeout variables. var timoutWarning = 840000; // Display warning in 14 Mins. var timoutNow = 100000; // Timeout in 15 mins would be 900000. var logoutUrl = 'logout.php'; // URL to logout page. var warningTimer; var timeoutTimer; // Start timers. function StartTimers() { warningTimer = setTimeout("IdleWarning()", timoutWarning); timeoutTimer = setTimeout("IdleTimeout()", timoutNow); } // Reset timers. function ResetTimers() { clearTimeout(warningTimer); clearTimeout(timeoutTimer); StartTimers(); $("#timeout").dialog('close'); } // Show idle timeout warning dialog. function IdleWarning() { // $("#timeout").dialog({ //modal: true alert("Warning, your page will redirected to login page. Due to not move your mouse within the page in 15 minutes."); //}); } // Logout the user. function IdleTimeout() { window.location = logoutUrl; }
javascript
Jayreis
source share