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
Post a Comment