Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to check if browser tab is active javascript

let browser_active = ((typeof document.hasFocus != 'undefined' ? document.hasFocus() : 1) ? 1 : 0);
if (!browser_active) {
 // active
} 
Comment

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;
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: data-toggle="tooltip not working due to jquery-ui.min.js 
Javascript :: react usecallback hook 
Javascript :: this function 
Javascript :: angular 7 selected 
Javascript :: express sendfile root path 
Javascript :: how to call mixin in vuex 
Javascript :: react state field declaration 
Javascript :: js class 
Javascript :: partial filter expression mongodb compass 
Javascript :: _.extend 
Javascript :: flatlist react native keyextractor 
Javascript :: socket io new server multiple origins 
Javascript :: node http request 
Javascript :: re init data vue js 
Javascript :: how to upload picture on canvas in react 
Javascript :: react onchange url 
Javascript :: cy.contains 
Javascript :: common javascript coding interview questions 
Javascript :: factorial program in javascript 
Javascript :: string properties in javascript 
Javascript :: textbox value length in javascript 
Javascript :: add marker on map geocoder result mapbox 
Javascript :: basic json syntax 
Javascript :: object loop javascript 
Javascript :: regex validations 
Javascript :: boolean javascript 
Javascript :: delete node between indexes node list js 
Javascript :: merge binary tree 
Javascript :: Nodemon continuously restart 
Javascript :: javascript eventlistener 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =