• Post category:JavaScript
  • Reading time:2 mins read

In this article, we will show you how to get the web page size 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 - Code Premix
Web page size – Code Premix

I hope you find this article helpful.
Thank you for reading. Happy Coding..!!

Leave a Reply