I have this piece of code at the start of my page’s script tag:
window.addEventListener('visibilitychange', function () {
console.log("in event handler: ", document.visibilityState);
if (document.visibilityState === 'hidden') {
console.log("stopping hub");
}
else {
console.log("starting hub");
}
}, false);
When the page runs in Edge or Firefox, this works perfectly.
Each time I switch tabs, I get a message with the appropriate vibility
flag. But when I run the same page on Chrome, I don’t get the console.log()
messages.
I just can’t figure out why chrome isn’t sending the page these messages.
I have also replaced with window
with document
.
Since I have jquery on this page, I have also used $(document).on()
.
Each time, everything works great in Edge / Firefox, but does not in Chrome.