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

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

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

19条回答
  •  鱼传尺愫
    2020-11-21 06:12

    You can also get the WINDOW width and height, avoiding browser toolbars and other stuff. It is the real usable area in browser's window.

    To do this, use: window.innerWidth and window.innerHeight properties (see doc at w3schools).

    In most cases it will be the best way, in example, to display a perfectly centred floating modal dialog. It allows you to calculate positions on window, no matter which resolution orientation or window size is using the browser.

提交回复
热议问题