patternjavascriptCritical
Get the size of the screen, current web page and browser window
Viewed 0 times
pagebrowserwebandthecurrentwindowscreensizeget
Problem
How can I get
windowWidth, windowHeight, pageWidth, pageHeight, screenWidth, screenHeight, pageX, pageY, screenX, screenY which will work in all major browsers?Solution
These days, for screen size you can use the
Legacy
You can get the size of the window or document with jQuery:
screen object:window.screen.height;
window.screen.width;Legacy
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();Code Snippets
window.screen.height;
window.screen.width;// Size of browser viewport.
$(window).height();
$(window).width();
// Size of HTML document (same as pageHeight/pageWidth in screenshot).
$(document).height();
$(document).width();Context
Stack Overflow Q#3437786, score: 1723
Revisions (0)
No revisions yet.