Reputation: 3362
How do check if a the user has the browser's tab/window currently on our page
function userisonourpage()
{
//do something
}
And when a user switches the tab/window to our page ?
function tabswitched()
{
//dom something here too
}
Just like in many places u switch to the page and the title changes i know the title can be changed with : document.title
but dont know how to implement those functions.
Thanks :D
Upvotes: 6
Views: 9481
Reputation: 18344
You could do this:
$(document).ready(function(){
$([window, document]).focusin(function(){
//Your logic when the page gets active
}).focusout(function(){
//Your logic when the page gets inactive
});
});
Hope this helps. Cheers
Upvotes: 13