1

How do I get the full height of the web page with javascript? For example, the web page is 4138 pixels. How do I get it with javascript ??? The clientheight only gives the height of the screen, I do not want this.

  • Please do some [search](https://stackoverflow.com/questions/1145850/how-to-get-height-of-entire-document-with-javascript) first. – Empty Brain Aug 05 '18 at 06:11
  • Please look around SO to find similar questions. Also try Googling your issue (or Bing or Yahoo or whatever) – Jack Bashford Aug 05 '18 at 06:11
  • 1
    Possible duplicate of [How to get height of entire document with JavaScript?](https://stackoverflow.com/questions/1145850/how-to-get-height-of-entire-document-with-javascript) – Empty Brain Aug 05 '18 at 06:12

2 Answers2

1

You can find the height of the webpage using outerHeight . You should have jQuery on the site. Use like this:

$('body').outerHeight()

For plain Javascript, use this code:

var height = document.querySelector('body').clientHeight
console.log(height)
Enamul Haque
  • 144
  • 9
0
To get the height of the Web Page using javascript, you can make use of the method "height". Here is an example where you can get the height of the webpage using javascript in pixel

<!DOCTYPE html>
<html>
<body>

<p>Click the button to display the total height of your screen, in pixels.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
    var x = "Height of the Screen in Pixel is : " + screen.height + "px";
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

So, the method "screen.height" will give you the height of the pixel.

  • This only returns the display's altitude. I want the page height of the web page. – mohammadreza seydi Aug 05 '18 at 07:04
  • Same question has been asked here, you can check this link for a verified answer https://stackoverflow.com/questions/1145850/how-to-get-height-of-entire-document-with-javascript – Jay Prakash Aug 05 '18 at 09:58