Search
 
SCRIPT & CODE EXAMPLE
 

HTML

how to find total height of single page page in html

function calculateTotalHeightMinusElement(excludeElementClass)
{
  // Get all child elements of the body tag
  var bodyChildren = (document.getElementsByTagName('body')[0]).children;

  var totalHeight = 0;

  // Loop through the selected elements
  for (var i = 0; i < bodyChildren.length; i++) {

    // Add the height of this element
    totalHeight = totalHeight + bodyChildren[i].offsetHeight;
  }

  // Get the height of the element we want to exclude
  var excludedElementHeight = document.getElementsByClassName(excludeElementClass)[0].offsetHeight;

  // Calculate height minus the excluded element
  var finalHeight = totalHeight - excludedElementHeight;

  // Display the final height in an alert
  alert("Total height: " + finalHeight);
}

document.addEventListener("DOMContentLoaded", function(event) {

  // Pass in the class name of the element you want to minus from the height calculation
  calculateTotalHeightMinusElement("myDivClass");
});
Comment

PREVIOUS NEXT
Code Example
Html :: floating modal bootstrap 
Html :: How to write the latex in html 
Html :: como limpar as informações de uma tabela html 
Html :: html input on enter 
Html :: symfony twig form value 
Html :: how link back to home page html without index 
Html :: x-auth-token 
Html :: how to type & in xml file 
Html :: aside html 
Html :: signature: Generated signature does not match submitted signature. 
Html :: alpinejs event target 
Html :: form boilerplate 
Html :: get all html element data using angular 
Html :: how to make a div a checkbox html 
Html :: how to put h1 in html 
Html :: html title attribute 
Html :: how to write h1 tag in html 
Html :: html code 
Html :: use html code for close icon after zoom imgage 
Html :: read only textview nativescript 
Html :: func.apply is not a function at HTMLUnknownElement.callCallback 
Html :: shchema keyref et key use 
Html :: return html in swal 
Html :: html endofline in td 
Html :: how to change the postion of text in html 
Html :: how to embed a chess in our blogger page 
Html :: HTML JWB2 
Html :: servicenow g: breakpoint 
Html :: html not showing image with full path 
Html :: eml vs emlx files 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =