1

Does anyone know the way to check full opening of window by Javascript?

    // code1 dont work
    $(window).resize(function() {
        ...
    });

    // code2 dont work
    window.onresize = function(event) {
        ...
    }

I wanna check the MOMENT when screen(of browser) go to fullscreen.

Charlie
  • 22,886
  • 11
  • 59
  • 90
nywuctuk2
  • 93
  • 5
  • Can you elaborate what you mean by "full opening window"? – wrxsti Dec 03 '15 at 13:26
  • 1
    This seems to be addressed in: http://stackoverflow.com/questions/2863351/checking-if-browser-is-in-fullscreen – AlwaysNull Dec 03 '15 at 13:31
  • Its not exactly right. I wanna check the MOMENT when screen(of browser) go to fullscreen. – nywuctuk2 Dec 03 '15 at 14:09
  • onresize should do it. How much of a delay are you observing? Is it firing too early? Too late? Also, in case it helps, remember there's a CSS media query for the fullscreen state. – Katana314 Dec 03 '15 at 14:40
  • You mean AFTER resizing has finished? Have a look at this http://stackoverflow.com/questions/4298612/jquery-how-to-call-resize-event-only-once-its-finished-resizing – StudioTime Dec 03 '15 at 14:43
  • Ty all! SetTimeout is good helper here too. – nywuctuk2 Dec 03 '15 at 18:26

2 Answers2

1

Compare the outerHeight and outerWidth of the window against the screen.availWidth and screen.availHeight

window.onresize = function(event) {
    if (window.outerWidth === screen.availWidth && window.outerHeight === screen.availHeight) {
        console.log("This is your MOMENT of fullscreen: " + Date());    
}
Charlie
  • 22,886
  • 11
  • 59
  • 90
  • I have some problems if panel of console is open here. Size of window changing then..But its not ctitical thing. – nywuctuk2 Dec 03 '15 at 19:27
  • I tested this in Chrome. Console view wouldn't effect the code since we are dealing with outerHeight and outerWidth. – Charlie Dec 04 '15 at 03:02
0
if( window.innerHeight == screen.height) {
    // browser is fullscreen
}

For the event see: Fullscreen API: Which events are fired?

Community
  • 1
  • 1
arhea
  • 454
  • 2
  • 5