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

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

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

19条回答
  •  爱一瞬间的悲伤
    2020-11-21 06:26

    You can get the size of the window or document with jQuery:

    // Size of browser viewport.
    $(window).height();
    $(window).width();
    
    // Size of HTML document (same as pageHeight/pageWidth in screenshot).
    $(document).height();
    $(document).width();
    

    For screen size you can use the screen object:

    window.screen.height;
    window.screen.width;
    

提交回复
热议问题