Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript detect if the browser tab is active

var interval_id;
$(window).focus(function() {
    if (!interval_id)
        interval_id = setInterval(hard_work, 1000);
});

$(window).blur(function() {
    clearInterval(interval_id);
    interval_id = 0;
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #detect #browser #tab #active
ADD COMMENT
Topic
Name
5+9 =