Getting height of div

I have a div :

<div id='inhoud' align='center' style= 'overflow: auto; margin-left: 0px; margin-top: 155px; width: 1010px; height: auto; position: absolute; background-color:Silver;'>{$setService()}</div>

with a dynamic height. How can I obtain the height of the div in php ?

The div :




should adapt to the height of the #inhoud div as you can see in the picture.

You can’t get the div’s height in PHP, as when the page is rendered and the div is displayed, PHP has already gone away. The only way to do that is to get the height with javascript, then get the image via AJAX.

If I place [php][/php] in the header the result is not written. But if I take away offsetHeight a null value is written.

What could be the problem ?

This works:


I get “38” in my console, so the problem must be elsewhere in your code.

I don’t have a console.

Then you should start using Chrome, or install firebug in firefox.

I already tried in Chrome but see no console.

Please try a google search next time

The console in IE is shown by F12.

How can I pass the javascript variable to php ?

anybody ?

use get, post or ajax.

I was thinking isn’t it possible for the bottom blue div (service):




to align automatically under the : [php]


As you can see in the picture where the arrow points.

On the website you see the footer div directly under the menu and content div. That is what I want with the service div, directly to appear under the inhoud div ?

Thanks in advance.

jimL do you know what I mean ?

I did a test with plain HTML and it works well (the bottom service div adapts to the height of the inhoud div):


Main Title of Web Page


Copyright © 2013 Fijenoord Ruilwinkel

as you can see in the picture. What could be the problem it doesn’t work in php ?

I already solved my problem.

Sponsor our Newsletter | Privacy Policy | Terms of Service