How to get the web page size in JavaScript
π
June 29, 2021
πJavaScript
In this article, we will show you how to get the web page size in JavaScript.
Recommended Articles:
- screen-size-in-javascript" title="How to get the screen size in JavaScript">How to get the screen size in JavaScript
- How to get the window size in JavaScript
Checkout more articles on JavaScript
- Set text direction based on input text language in JavaScript
- math-functions-in-javascript" title="Math functions in JavaScript">Math functions in JavaScript
- console methods in JavaScript
- browser-back-button-using-javascript" title="How to disable the browser back button using JavaScript">How to disable the browser back button using JavaScript
- How to merge arrays in JavaScript
Get the web page size
To get the web page size, we need to get the `scrollWidth` and `scrollHeight` of the page content.
Use the following code to get the web page size.
const pageWidth = document.documentElement.scrollWidth; // Output: 838
const pageHeight = document.documentElement.scrollHeight; // Output: 4110
Check the following image for your reference.
Web page size - Clue Mediator
I hope you find this article helpful.
Thank you for reading. Happy Coding..!! π