Please I'd like to count the time spent on a given page. In order to do this, I need to know when the page is opened in new tab, without focus and then start counting when the tab has focus.
$(window).focus(function() {
window_focus = true;
}).blur(function() {
window_focus = false;
});
The above works well when the has already loaded on a focused tab. How can I know when a page is fully loaded without focus.