I'm trying to finish a module that adds some value to ServiceLinks, and i have run into a DHTML snag, and was hoping a few gurus could help me on this.

I am trying to set a table cell height by setting a div inside it.

Thus, I want to set the div height to the overall height I desire the
cell to be. Alas, browsers seem to include padding and borders in the offsetHeight
property,but NOT margins. I need to get that to calculate properly.

Unfortunately, I can't seem to read the element.style.margin value in
any possible combination. (I can get borders and padding by
subtracting style.height from offsetheight).

I have tried style.marginLeft, and all permutations. I am searched the
web can cannot find any reference to reading this attribute. Everything I read says that margin is read/write.. and yet I can't seem to read it.

Can anyone solve this?

You would think it would simply be this (but it's not)

var margin = parseInt(element.style.marginWidth);

Comments

MatteBlack’s picture

No sooner did I post this, than I changed my search strategy a bit,and looked for ways to get the global CSS cascades.and found this. SUre enough, it had a cross browser way to get the margin attribute. I hope this post gets crawled by anyone looking for this solution. It was a bear to find :)

http://www.javascriptkit.com/dhtmltutors/dhtmlcascade4.shtml