Scripts: Javascript :: Forms :: Library Article #29
Developer's Section
Calculating offsetHeight and innerHeight of elements returning 0 value when using DOCTYPES By: Erobo Team Member
|
|||
In this tutorial we will be looking at a technique to calculate the offsetHeight and innerHeight of html elements when the browser can not correctly determine the value for these properties.
Sometimes when working with Doctype documents you will come across instances where innerHeight and offsetHeight properties of an html element return a 0 value. This usually happens when some of the elements on the html document have a display:none style and are configured to show on hover. Also, sometimes this case is seen on floating elements, and divs with position:absolute style.
test
innerHeight or offsetHeight of some content inside To solve this issue, you could create a helper DOM element that matches the style of the element that you are trying to calculate the height for. Inserting it at the beginning of the document. Calculating the height, and then removing it completes the process easily. Thus providing a convenient way of achiving this goal without any major implications. See Code Below: |
|||
|
|||
See other Scripts in Forms |
Submit Your Scripts: |
System Message:
|
If you would like to have your Javascripts published in this section please fill out the form below: |