如何通过Javascript检查完整的打开窗口?

时间:2015-12-03 13:25:45

标签: javascript jquery

有没有人知道通过Javascript检查窗口完全打开的方法?

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

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

我想在屏幕(浏览器)进入全屏时检查MOMENT。

2 个答案:

答案 0 :(得分:1)

将窗口的outerHeightouterWidthscreen.availWidthscreen.availHeight

进行比较
window.onresize = function(event) {
    if (window.outerWidth === screen.availWidth && window.outerHeight === screen.availHeight) {
        console.log("This is your MOMENT of fullscreen: " + Date());    
}

答案 1 :(得分:0)

if( window.innerHeight == screen.height) {
    // browser is fullscreen
}

有关活动,请参阅:Fullscreen API: Which events are fired?