-5

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.

SmileAshis
  • 93
  • 1
  • 5
  • 12

1 Answers1

1
$(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.

nnnnnn
  • 147,572
  • 30
  • 200
  • 241
  • Thanks. But i want the mechanism like windows screensaver does nd there only VDU present no keyboard or mouse,only touch are applicable there. – SmileAshis Dec 17 '12 at 04:01
  • Touch events? Then just make the obvious substitution. (Or you may find that touch events cause a click anyway and you don't need to change it.) I'm at a loss as to what you mean about the Windows screensaver. – nnnnnn Dec 17 '12 at 04:06
  • suppose after using this application sometimes user may not be back to the main screen or home page. So i want to automatically redirect when user interaction will not done in a certain time,the application automatically redirect to home page. – SmileAshis Dec 17 '12 at 04:15
  • Yes, that's what your question said, so that's what the code I've shown will do - I haven't just supplied you with a random function. Put it in a JS file and include on every page (except the main one). Just put the appropriate url where I've got `"homePage.htm"`. – nnnnnn Dec 17 '12 at 04:19
  • nope dear. You have written mousemove keydown click event but when a user left the screen no interaction will occurred i think. After sometime like 5 or 10min it will automatically redirect home page without any evnt like mousemive,click or keydown. – SmileAshis Dec 17 '12 at 04:23
  • Instead of dismissing my code without understanding it why don't you try it? http://jsfiddle.net/R8nk3/ I _know_ what I've written, and it does what you've asked. Study it more carefully. – nnnnnn Dec 17 '12 at 05:15