سؤال

I have created a web application KIOSK. But my prob is suppose a user uses the KIOSK application, nd after used this application the user left the screen. Another user come and the user will not see the home page.

So i want to create a system that after used this application, the application wait for user interaction. If no interaction occurred the application automatically redirect to the main screen or home page after specific time.How to do this.Thanks in advanced.

هل كانت مفيدة؟

المحلول

$(document).ready(function(){
    var timeout;
    $(document).on("mousemove keydown click", function() {
        clearTimeout(timeout);
        timeout = setTimeout(function() {
             window.location = "homePage.htm";
        }, 2 * 60 * 1000);
    }).click();
});

All of the functions used above are well documented at either the jQuery site or MDN.

EDIT - Explanation of how this works: it sets a timer to redirect after two minutes. (Obviously this time can be adjusted.) If the user moves the mouse, clicks or types then clear the timer and set a new one. Trigger this handler once when the page first loads to start the first timer.

So if the user doesn't trigger the handler within the 2 minute period the redirect will occur.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top