How can I get windowWidth
, windowHeight
, pageWidth
, pageHeight
, screenWidth
, screenHeight
,
You can use the Screen object to get this.
The following is an example of what it would return:
Screen {
availWidth: 1920,
availHeight: 1040,
width: 1920,
height: 1080,
colorDepth: 24,
pixelDepth: 24,
top: 414,
left: 1920,
availTop: 414,
availLeft: 1920
}
To get your screenWidth
variable, just use screen.width
, same with screenHeight
, you would just use screen.height
.
To get your window width and height, it would be screen.availWidth
or screen.availHeight
respectively.
For the pageX
and pageY
variables, use window.screenX or Y
. Note that this is from the VERY LEFT/TOP OF YOUR LEFT/TOP-est SCREEN. So if you have two screens of width 1920
then a window 500px from the left of the right screen would have an X value of 2420
(1920+500). screen.width/height
, however, display the CURRENT screen's width or height.
To get the width and height of your page, use jQuery's $(window).height()
or $(window).width()
.
Again using jQuery, use $("html").offset().top
and $("html").offset().left
for your pageX
and pageY
values.