jquery - execute a javascript function if the user is not active on the page? -


i'm looking javascript or jquery function execute function newalert() if user not active on page, ( maybe event check cursor position or )

i make auto check using settimeout , want function check availability of user in gmail chat, when receiving new im , not watching gmail page, plays bleep sound.

thanks

try using window.onblur event, or can have timer running continuously , when mouse position same x amount of milliseconds, execute function.

example:

var lastx, lasty = 0; var act_timeout = null; function doaction() {    alert( 'not active' );    return false; } function move( e ) {    if( e.clienty == lasty && e.clientx == lastx ) {        act_timeout = settimeout( doaction, 5000 );        return;    }    lastx = e.clientx;    lasty = e.clienty;    act_timeout = cleartimeout( act_timeout ); } window.onmousemove = move; window.onblur = doaction; 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -