I am dynamically outputting a list of <dl> elements that i am displaying in a grid with css float. One of the elements contained in the <dl> is an image, which is a variable size. Here's the essential html structure of each <dl>.
Code:
<dl class="IDG_product">
<dt>name</dt>
<dd><a href="page.asp"><img src="img.jpg"></a></dd>
<dd class="IDG_itemNumber">A230</dd>
<dd class="IDG_productPrice">$4.50</dd>
</dl>
The variable height image is causing the height of the entire <dl> to vary, throwing off the float. To fix this I'm attempting to resize all the <dl>s to the height of the largest one in the set. This code below works fine in IE 6, but has no effect in Mozilla 1.6. I suspect IE is once again fooling me into thinking I've written compliant code by being too forgiving. What is the proper way to set a height/width of a node after retrieving it's offsetWidth/Height?
Code:
function sizeProductContainers()
{
if (document.getElementById)
{
var maxHeight = 0;
var maxWidth = 0;
var navRoot = document.getElementById("IDG_productList");
for (i=0; i<navRoot.childNodes.length; i++)
{
node = navRoot.childNodes[i];
if (node.className == "IDG_product")
{
if (node.offsetHeight > maxHeight)
maxHeight = node.offsetHeight;
if (node.offsetWidth > maxWidth)
maxWidth = node.offsetWidth;
}
}
for (i=0; i<navRoot.childNodes.length; i++)
{
node = navRoot.childNodes[i];
if (node.className == "IDG_product")
{
node.style.height = maxHeight;
node.style.width = maxWidth;
}
}
}
}
window.onload = sizeProductContainers;