I made a test-case to see if I could get full-screen detection to work
reliably cross-browser. For the most part, it works...

http://host.sonspring.com/_misc/detect_full_screen.html

Code posted as a gist on GitHub...

https://gist.github.com/978838

What's interesting is that Firefox reports documentElement's height to
be -1px less than screen height, when full-screen, because it leaves a
1px black border at the top of the page, where the address bar will
slide down, if you mouse-over.

Also, IE9 reports +16 wider for window.outerWidth, beyond the screen
width. But this is easily mitigated by using window.innerWidth
instead, as all browsers handle that correctly.

Also worth noting: This doesn't seem to work in IE7 or IE8 (testing
modes, via IE9) because they don't understand window.{width/height},
and the status bar, present when full screen, throws off the
calculation of documentElement dimensions.

(Since I only have one screen on my Windows VM, I can't verify the
previous claims about it reporting only primary screen width, not
external monitor.)

--
Nathan Smith
http://sonspring.com



On Thu, May 19, 2011 at 7:03 AM, Poetro <[email protected]> wrote:
> 2011/5/19 Matthias Reuter <[email protected]>:
>>> I imagine a use case where a webapp hides some if its UI elements when a
>>> user goes fullscreen, giving him more of actual content area. Not
>>> necessarily an always desired behaviour but interesting.
>>
>> I think it's easier to detect fullscreen mode than a maximized window. A
>> script might detect fullscreen by comparing screen.width and
>> document.documentElement.clientWidth (resp. height):
>>
>> function isFullScreen () {
>>    var docEl = document.documentElement;
>>
>>    return screen.width === docEl.clientWidth && screen.height ===
>> docEl.clientHeight;
>> }
>>
>> Matt
>>
>
> This can have issues in case of multiple screens. Opera and Internet
> Explorer always returns the width/height of the primary screen, while
> Firefox and Chrome returns it for the screen the window is currently
> on (or at least what the OS suggests it is on atm).
>
> --
> Poetro
>
> --
> To view archived discussions from the original JSMentors Mailman list: 
> http://www.mail-archive.com/[email protected]/
>
> To search via a non-Google archive, visit here: 
> http://www.mail-archive.com/[email protected]/
>
> To unsubscribe from this group, send email to
> [email protected]
>

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to