Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checking if browser is in fullscreen [duplicate]

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.

like image 609
Mark Avatar asked May 19 '10 06:05

Mark


People also ask

How do I tell if an element is fullscreen?

Tip: Use the element. requestFullscreen() method to view an element in fullscreen mode. Tip: Use the element. exitFullscreen() method to cancel fullscreen mode.

How do I fix my browser full screen?

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 .

How do I make sure Chrome is full screen?

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.

Is Full screen Javascript?

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.


2 Answers

This works for all new browsers :

if (!window.screenTop && !window.screenY) {     alert('Browser is in fullscreen'); } 
like image 90
Tom Ulatowski Avatar answered Sep 23 '22 16:09

Tom Ulatowski


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 {  } 
like image 38
user4815162342 Avatar answered Sep 24 '22 16:09

user4815162342