While going through a interview, a interviewer asked me this question which made me to think over it.
The question was:
I have a web page and i want that, if a user not perform any operation (enter text or select a item from dropdownList or any other such) for last 5 minutes on that page then he should be prompted by a message.
i answered the question but he was not looking satisfied. Later when i worked over it and got to know that my answer was correct but its was not optimized.
so below is an optimized solution for such problem:
in above example we are using jquery to binding all required event listeners with a timer to trigger our function which will prompt user that your are idle on page form last 5 minutes.
For more ASP.NET interview questions click here
Read More
The question was:
I have a web page and i want that, if a user not perform any operation (enter text or select a item from dropdownList or any other such) for last 5 minutes on that page then he should be prompted by a message.
i answered the question but he was not looking satisfied. Later when i worked over it and got to know that my answer was correct but its was not optimized.
so below is an optimized solution for such problem:
$(window).bind( 'mousemove mouseclick keydown mousewheel ...more listeners...', idle ); function idle( e ) { if ( window.idleTimeout ) { clearTimeout( window.idleTimeout ); } window.idleTimeout = setTimeout( userIdle, 300000 ); } function userIdle() { //either do stuff here or trigger the "idle" event $(window).trigger('idle'); }
in above example we are using jquery to binding all required event listeners with a timer to trigger our function which will prompt user that your are idle on page form last 5 minutes.
For more ASP.NET interview questions click here