Code Premix

JavaScript get the web page size

๐Ÿ“…July 6, 2022
๐Ÿ—JavaScript

In this article, we will show you how to get the web page size in JavaScript.

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.