views:

30

answers:

2

Hello again,

I don't want to open my site in fullscreen mode (as it's not possible without using Flash) or to open it in 'kiosk mode'.

I want to ask the user to press F11 on his/her keyboard to turn the browser into fullscreen mode. And I want to know if he/she did it. Is there a way to determine if the current window is being browsed in fullscreen mode?

Thanks in advance for your answers, Michael

+1  A: 

You could play with screen.width/height and document.body.clientWidth/Height but I've never tried...

bazmegakapa
That is not completely bad idea. I could check for example if(screen.height - document.body.clientHeight < 50) and assume that if it's true, the site is in fulscreen mode. But it depends also on the user's View settings - if he/she hides all the toolbars and so on - the clientHeight may be almost like in fullscreen mode but it actually is not. I will use your solution for now but I'm still waiting for another advices. Nevertheless, thank you!
kremuwa
@kremuwa: if you can take that approach (i.e. not being exact), then you'll be OK. Look at my example, and use document.documentElement.clientHeight (anc .clientWidth) for IE. The title bar should add on about 80 pixels, but the status bar is removed from IE's height value, so you need to take that into account. It's tricky, but you should be able to be 'fairly confident' that full screen mode is in use
Bobby Jack
Ok, thanks again, look at my comment above :)
kremuwa
+1  A: 

This works for me, in firefox 3.6, at least:

function is_fullscreen()
{
    return window.outerWidth == screen.width && window.outerHeight == screen.height;
}

I suggest you confirm that's the behaviour you want in Firefox, then test it in other browsers. If other browsers fails, you'll need to investigate how their implementations of those properties differ; I have a bad feeling they will.

Update: It certainly doesn't work in IE7.

Bobby Jack
It seems that in IE outerWidth/Height properties are undefined. But it does not make me sad, because I need my app to work only in Firefox and Chrome. And because of that I accept your answer :). Thanks!
kremuwa
in Firefox there is also a window.fullscreen property
bazmegakapa
Excellent - that's a luxury any of us rarely has! :) See my comment on the other answer re: IE-handling, if you really want to. It's also worth noting that, if the height problems are really a stumbling block, you *could* just inspect width. In theory, a non-fullscreen window should always include at least a pixel border either side (mine has 2 pixels either side), meaning that window width will only ever equal screen width if full-screen mode is on. I'm not sure how weird side-panels might affect that, though, so you should probably test those too.
Bobby Jack
@bazmegakapa: well that sounds like a better option all round! :)
Bobby Jack