I'm writing this module which outputs a block to a sidebar (containing banner ads). I'd like this module to check the height of the main content div, to be able to determine how many banners that fits on that particular page.

Don't know much about javascript/jquery/AJAX etc, but I know how to check the height of a div. Is it possible to return this value back to the module?

I'd be very grateful for any help on this. I'm slowly going insane trying to figure this out... :)

Comments

danielb’s picture

Yup It's possible in both js and jquery, here's the jquery way:

http://docs.jquery.com/CSS/height

so it's basically just
var divheight = $("div#something").height();

In javascript I think it's 'offsetheight' you would be interested in.

Standard’s picture

Thanks, but that's the "easy" part : )

What troubles me is passing that information back to my module – before the page has been built.

Any ideas?

pearl's’s picture

Hi ,
while searching the same i got collected a good example for the thing
You can get a well described example at: http://languagelassi.blogspot.in/2013/01/how-to-detect-height-of-element-in.html

And as you are working on Ready event it will modify your page before page rendered.