I was trying to use Visibility API, but it is not working for a child. The minimal example to reproduce:
<script>
document.onvisibilitychange = () => {
console.log(document.visibilityState);
}
if (!window.opener) {
window.open(window.location.href, '_blank');
}
</script>
After that, the parent window still prints "visible"-"hidden", but child prints "hidden" once only on refresh.
It works fine in the latest Opera browser, but not in the Chrome
To be honest, when I came to this minimal reproduce, I'm stuck and have no idea where to dig. Any ideas what could be wrong?
Note: The Page Visibility API is especially useful for saving resources and improving performance by letting a page avoid performing unnecessary tasks when the document isn't visible.
The visibilitychange event is fired at the document when the contents of its tab have become visible or have been hidden. The event is not cancelable.
I also stumbled over this issue. I think that this bug was introduced in Chrome 84. I testet it with version 83 and it worked as expected. The current Canary-Build (Version 86) is also working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With