Get the size of the screen, current web page and browser window

前端 未结 19 2367
面向向阳花
面向向阳花 2020-11-21 05:29

How can I get windowWidth, windowHeight, pageWidth, pageHeight, screenWidth, screenHeight,

19条回答
  •  滥情空心
    2020-11-21 06:33

    In some cases related with responsive layout $(document).height() can return wrong data that displays view port height only. For example when some div#wrapper has height:100%, that #wrapper can be stretched by some block inside it. But it's height still will be like viewport height. In such situation you might use

    $('#wrapper').get(0).scrollHeight
    

    That represents actual size of wrapper.

提交回复
热议问题