How to fix the issue of mouse-pointer?

130 views Asked by At

I'm using PHP, jQuery, JavaScript, etc. for my website. Now, requirement is a script in jQuery/JavaScript which will give alert to the user when the mouse-pointer is away from the tab in which webpage from my website is opened.

Can anyone help in this regard? Any kind of help would be highly appreciated.

2

There are 2 answers

7
Cracker0dks On

use

$(document).focusout(function() { 
       alert("your out"); 
});
0
CJ Ramki On

I think @Cracker0dks's answer is the best way,

$(document).focusout(function() { 
       alert("your out"); 
});

If you want to track shortcut keys using jquery keypress events, you should know about the key codes of key board buttons. And alert user if they presses what combination of keys you want to track.

to know about key codes, visit this url http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00000520.html

but If the user presses any short cut keys to minimize windows you can just show alert in the browser page only. After minimize user can't see your alert message.

You could also use it like in this fiddle DEMO