2

Is there a way to detect when a browser exits full screen mode using javascript?

Background info:
I am working on an HTML5 Player and have a button to enter full screen.
When in full screen mode, I want the toolbar (for the player) to be hidden.
Then when user exits full screen mode I want the toolbar to be visible again.
I am able to detect when the fullscreen button I added is clicked, and when escape key is pressed.
However, I am not able to determine when the browser message "Exit Full Screen" is clicked.

Problem:
I need to know how to add an event or somehow detect when a user clicks
"Exit Full Screen (Esc)" when in full screen mode so I can get the player to
show my toolbar. Adding an event to the escape key did not fix my problem.

kristadev
  • 21
  • 4
  • Hey @ksol, in order for people to really help you I'd recommend making your questions readable (i.e. use newlines, punctation). Also, when putting code in your questions, use the proper code styling present in the text editor of Stackoverflow. Lastly, we need to see more code than what you posted. – Glubus Feb 19 '16 at 16:11
  • I updated my question a bit. I don't need help with my code on making the toolbar visible, I just need to know how I can detect when the browser's message "Exit Full Screen (Esc)" is clicked (not when the user presses the escape key). – kristadev Feb 19 '16 at 17:11
  • 1
    I think this has been already answered in another post [here](http://stackoverflow.com/questions/10706070/how-to-detect-when-a-page-exits-fullscreen) – pakallis Feb 19 '16 at 17:22
  • if (document.addEventListener) { document.addEventListener('webkitfullscreenchange', exitHandler, false); document.addEventListener('mozfullscreenchange', exitHandler, false); document.addEventListener('fullscreenchange', exitHandler, false); document.addEventListener('MSFullscreenChange', exitHandler, false); } function exitHandler() { if (document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement !== null) { /* Run code on exit */ } } – kristadev Feb 19 '16 at 17:54
  • I tried that code I just put above and it didn't work... – kristadev Feb 19 '16 at 17:54
  • Possible duplicate of [How to detect when a page exits fullscreen?](https://stackoverflow.com/questions/10706070/how-to-detect-when-a-page-exits-fullscreen) – Eliran Malka Apr 15 '19 at 23:00

0 Answers0