Skip to content Skip to sidebar Skip to footer

Window Focus Not Working In Chrome When Switch Tabs

(function($){ $(window).focus(function(){ document.title = 'focused'; }); $(window).blur(function(){ document.title = 'not focused'; }); })(jQuer

Solution 1:

Check out this answer, you could easily modify that code to complete the task you've outlined here.

Solution 2:

This is in fact a reported bug of Chrome and it is happening in version 29, when you change between tabs. It seems to be a race condition that will not update the title of the tab, despite the fact that document.title is correctly filled.

A possible workaround for the code above is to create a timer to change the title again. The following code works, but you can also just set the text inside the timer function.

(function($){

$(window).focus(function(){
    document.title = 'focused';
});

$(window).blur(function(){
    document.title = 'not focused';

    window.setTimeout(function () {
        var temp = document.title;
        document.title = temp + "_";
        document.title = temp;
    }, 200);
});

})(jQuery);

Post a Comment for "Window Focus Not Working In Chrome When Switch Tabs"