javascript - Fire function when returning to a tab -


i'm looking javascript / jquery method fire function when returning tab. i'm tracking amount of time spent on ad using getdate on load, , subtracting difference when leaving ad. however, links ad lead new tab, , user may return keep interacting ad. can used restart timer when user navigates tab? onload won't seem work since tab loaded, , onfocus fires many times (the user interacts ad perform live search of inventory). suggestions?

something should trick:

$(window).on('blur focus', function(e) {   // window has been focussed, when blurred.   if(e.type == 'focus' && $(this).data('type') == 'blur') {     alert('you have returned!')   }   // store event type.   $(this).data('type', e.type) }) 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -