Windows中的窗口调整大小无法正常工作

时间:2017-11-02 14:38:16

标签: javascript jquery

我有下面的jQuery函数,它意味着在窗口加载时删除一个类,如果宽度大于992 px则调整大小,如果小于992px则添加一个类。

似乎工作正常,但是如果我将窗口大小从992增加到1010px,则类会保持添加。在1011px它被移除。

sql = ('SELECT exampleschema.foo FROM bar;')

1 个答案:

答案 0 :(得分:1)

我曾经和类似的东西摔跤过。这是我的kludge修复。

var windowHeight = 460;
var windowWidth = 800;
if (document.body && document.body.offsetWidth) {
    windowHeight = document.body.offsetHeight;
    windowWidth = document.body.offsetWidth;
}
if (document.compatMode == 'CSS1Compat' && document.documentElement && document.documentElement.offsetWidth) {
    windowHeight = document.documentElement.offsetHeight;
    windowWidth = document.documentElement.offsetWidth;
}
if (window.innerWidth && window.innerHeight) {
    windowHeight = window.innerHeight;
    windowWidth = window.innerWidth;
}

if(windowWidth  > 992) {
     $('.bid-overlay-booking').removeClass('fancyboxID-booking');
}
else{

     $('.bid-overlay-booking').addClass('fancyboxID-booking');
}