screen.width
and screen.height
tell you the user's screen resolution, so try the following:
var fullscreen; function onfullscreenchange(full) { ... } // You might want to use addEventListener and its equivalents instead window.onresize = function () { if (window.outerWidth === screen.width && window.outerHeight === screen.height) { if (!fullscreen) { fullscreen = true; onfullscreenchange(true); } } else { if (fullscreen) { fullscreen = false; onfullscreenchange(false); } };
I know that this is not the cleanest or most reliable way to do all this, but hopefully it gives you an idea. It is noteworthy that IE <9 needs a different approach to determine the size of the window, so I will leave you to review.
source share