Jump to content

Detect Firefox Fullscreen


tinfanide

Recommended Posts

It's in the W3Schools reference: http://w3schools.com/jsref/obj_screen.asp availWidth contains the width of the screen excluding the task bar, availHeight contains the height of the screen excluding the task bar. You can test availWidth and availHeight compared to width and height. If they're both equal, then it's probably in full screen mode.

Link to comment
Share on other sites

I try this:

 document.write(screen.height);document.write(screen availHeight); 

But when I press F11 in FF, it turns to its full screen mode but the screen availHeight is still not equal to screen height.Then how can I compare them to detect if users open FF in fullscreen mode? This is my script to detect the full screen mode:

function fullscreenConfig(){    if(navigator.userAgent.indexOf("Firefox")!=-1){        var fullscreenReminder = document.createElement("div");        fullscreenReminder.style.color = "white";        fullscreenReminder.innerHTML = "Press F11 on the keyboard to enjoy a fullscreen view of the gallery";        document.body.appendChild(fullscreenReminder);        if(parseInt(screen.availWidth) == parseInt(screen.width) && parseInt(screen.availHeight) == parseInt(screen.height))(alert("Fullscreen Mode"))        }    }

Link to comment
Share on other sites

The numbers don't update automatically. When you change to full screen, the values printed there are still the old ones. Try running a function that prints the value when a button is clicked. Remember that some computers have the task bar on the bottom or top, while others have it on the sides, so you have to test both.

Javascript:function testSize() {  document.getElementById("output").innerHTML = "Full height: " + screen.height + "\nAvailable height: " + screen.availHeight;  document.getElementById("output").innerHTML += "Full width: " + screen.width+ "\nAvailable width: " + screen.availWidth;} HTML:<button type="button" onclick="testSize()">Click</button><div id="output"></div>

Link to comment
Share on other sites

Well... I've tested the script. My screen resolution is: 1920*1080. When I click in non-fullscreen FF, the availHeight is 1040;When I run FF in fullscreen, I refresh the page and click the button again, the availHeight is still 1040. So I think it's impossible to detect if FF users switch to the fullscreen mode.

Link to comment
Share on other sites

It seems that even when in full screen, the task bar doesn't actually disappear, so using the availWidth property won't help. I just tested, using window.outerWidth and window.outerHeight you can detect the size.

if(window.outerWidth == screen.width && window.outerHeight == screen.height) {  // The browser is in full screen mode}

outerWidth and outerHeight are exclusive to Firefox

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...