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

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

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

19条回答
  •  -上瘾入骨i
    2020-11-21 06:25

    Here is a cross browser solution with pure JavaScript (Source):

    var width = window.innerWidth
    || document.documentElement.clientWidth
    || document.body.clientWidth;
    
    var height = window.innerHeight
    || document.documentElement.clientHeight
    || document.body.clientHeight;
    

提交回复
热议问题