Imx Fix in my experience
« prev next »

June 26, 2003 2:08 AM

Safari reports the length of the cells[] array of a table row as zero, even if it has multiple cells. Look at the table below, if you mouse over it in a Gecko browser, or IE, you will see the background color of the table cells turn color. We do this by placing an onmouseover in the TR tags...
<tr onmouseover="color(this)">
And that "color" function takes over and says...
function color(obj) {

	for (var i=0; i < obj.cells.length; i++) {

		obj.cells[i].style.backgroundColor = '#FFFFCC';
So, onmouseover, the TR object gets passed and the function runs a loop using the length of the TR cells[] array as a stop point. In each iteration of the loop, it sets the backgroundColor to a light yellow and then we use an onmouseout to clean up after it, using almost the same exact function, only with a different name and different color (in this case, light grey, or #CCCCCC).

_Row_1_Cell_1_ _Row_1_Cell_2_ _Row_1_Cell_3_ _Row_1_Cell_4_ _Row_1_Cell_5_ _Row_1_Cell_6_
_Row_2_Cell_1_ _Row_2_Cell_2_ _Row_2_Cell_3_ _Row_2_Cell_4_ _Row_2_Cell_5_ _Row_2_Cell_6_
_Row_3_Cell_1_ _Row_3_Cell_2_ _Row_3_Cell_3_ _Row_3_Cell_4_ _Row_3_Cell_5_ _Row_3_Cell_6_
_Row_4_Cell_1_ _Row_4_Cell_2_ _Row_4_Cell_3_ _Row_4_Cell_4_ _Row_4_Cell_5_ _Row_4_Cell_6_

It's a part of DOM1 and supported back from Nav4 and IE4, so I'm guessing this is an oversight(?) Which isn't to surprising, because this isn't one of those make or break implementations, but it is REALLY useful for helping users track across an HTML table of financial data.

[I don't mean to pick on Safari this week, I just happen to be dealing with it a lot and am finding some issues. I'm trying to help out by writing test cases and send them to the mother ship.]

[Update: Safari 1.1 doesn't fix the cells[] array.]
[Update: Safari 1.2 (which is Panther only) fixes the cells[] array.]