Answers for "js check if tab switched"

0

js if tab is active

$(window).on("blur focus", function(e) {
    var prevType = $(this).data("prevType");

    if (prevType != e.type) {   //  reduce double fire issues
        switch (e.type) {
            case "blur":
                // do work
                break;
            case "focus":
                // do work
                break;
        }
    }

    $(this).data("prevType", e.type);
})
Posted by: Guest on February-18-2021
1

js check if tab switched

document.hidden
Posted by: Guest on July-13-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language