I want to end the fullscreen mode when the tab is changed or quickly switched. Is it possible to do it with javascript?
I have the following javascript code which ends fullscreen I want help in detecting the change in inter chrome tabs [using ctrl + tab shortcut] also in detecting the change in windows tabs like when a person switch chrome(any browser) to file explorer (for example)[using alt + tab shortcut].
My javascript code --
if (document.exitFullscreen) {
document.exitFullscreen();
}
else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
}
else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
I want to wrap this code in the switch tab function. Please help.
I also tried -
document.addEventListener("visibilitychange", function tabsswitch() {
if(document.hidden) {
alert('document hidden')
}
});
but that's not working when i change the windows tab for instance like i switch from chrome to my code editor and again back to chrome it does't show any alert.