I am trying to dynamically set the height of the contents of a web page by subtracting the header and footer values from the window size and setting the contents for this value when loading the document.
Each of the function parameters takes an element identifier to capture the height of the element; excluding the content parameter.
function setH(header, content, footer) { winH = top.innerHeight; winTitle = 32; // height value of the window title (part of the header) headH = $(header).outerHeight(true); footH = $(footer).outerHeight(true); contentH = winH - winTitle - headH - footH; $(content).css({'height' : (contentH) + 'px','overflow-y' : 'scroll'}); }
The problem I am facing is outerHeight values returning incorrect values. The header returns 23px and the footer is 40px.
When checking items in FF and Chrome, the values are 25px and 44px.
I tried using innerHeight, outerHeight and outerHeight (true) but did not get the correct values.
Any suggestions on what could go wrong? or an alternative way to dynamically determine the height of content? I'm running out of hair, so any help is appreciated.
Edit: I am working with content in an iframe. Next: winH = top.innerHeight gets the height value of the top top iframe.
seen_my_dog
source share