Possible Duplicate:
Detecting if a browser is in full screen mode
Is there a way to check if a browser is currently in fullscreen mode (after the user pressed f11)?
Something like:
if (window.fullscreen) { // it's fullscreen! } else { // not fs! }
Thanks.
Steerpike's answer is pretty good, but my comment:
Thanks a lot, but this answer is not sufficient for FF. In Chrome I can set a small tolerance, but in FF the urlbar and tabs takes a while to disappear, which means after pressing f11, the detected window.innerWidth is still too small.
Tip: Use the element. requestFullscreen() method to view an element in fullscreen mode. Tip: Use the element. exitFullscreen() method to cancel fullscreen mode.
Pressing the F11 key again allows you to go back to normal view. If pressing F11 does not have any effect, you may need to press the Fn key, and while holding it down, press F11 .
The quickest way to get Chrome in full-screen mode in Windows is to press F11 on the keyboard. The other way is through the Chrome menu: In the upper-right corner of Chrome, select the menu (three-dot) icon. In the Zoom section, select the square icon on the right.
Full-screen can be activated for the whole browser window by pressing the F11 key. It can be exited by pressing the Esc button. It is also possible to make a specific element in the page to enter and exit full-screen mode programmatically using Javascript Fullscreen API.
This works for all new browsers :
if (!window.screenTop && !window.screenY) { alert('Browser is in fullscreen'); }
In Firefox 3, window.fullScreen works (https://developer.mozilla.org/en/DOM/window.fullScreen).
So, you could potentially do something like this:
if((window.fullScreen) || (window.innerWidth == screen.width && window.innerHeight == screen.height)) { } else { }
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