Why does Firefox return 0 as the value of $(window).height()

前端 未结 7 918
野性不改
野性不改 2021-01-04 12:41

It seems to me that Firefox ought to be better equipped to return the proper value when using $(window).height().

I am using jQuery 1.8.2. Is this a bug

7条回答
  •  暖寄归人
    2021-01-04 13:09

    Try this function:

    function GetBrowserDim() {
        if (window.innerHeight) {
            return { w: window.innerWidth, h: window.innerHeight};
        } else {
            return { w: document.body.clientWidth, h: document.body.clientHeight };
        }
    }
    

提交回复
热议问题