» in my experience...

» home | about | contact | résumé
» archives | donate | rss syndication

»
»
I own this record.


Communiblog Communiblog expressed as RSS 2.0
Here at IMX
Memes R' Us
freetheaudio2.jpg
SuperNova 1987A from 1994 to 2003
GarageBand

Lesson Learned. « prev
Purdy. » next
cells[] array broken in Safari (?)
[ Posted by Dan on June 26, 2003 | 6 Comments ]

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.]

 

Can't you just set the background color of the TR instead of looping through the cells?

-Posted by Eric on June 26, 2003 06:01 PM

Well, the answers are yes, and no, and that's not the point.

The 'yes' part is that you can style the TR and it will work fine in Safari. The 'no' part is that Camino (and Gecko at large) seems to consider traveling out of the border region of a TR into a TD as a 'mouseout' from the TR and thus you get less than desireable results (and now I wonder if that's "the way it's upposed to be").

The 'that's not the point' part is that Safari reports the length of the cells[] array of a TR to be zero, no matter how many cells might actually be in there.

If that's fixed, then my script works everywhere, and reliably, which are two words I almost never use together when talking about JavaScripts. So perhaps I'm just dreaming ;)

-Posted by Dan on June 27, 2003 09:22 AM

We fixed this in WebCore shortly after 1.1. Look for it in the next release.

dave

-Posted by hyatt on December 9, 2003 02:48 PM

For Safari version 1.0 "cells" has been replaced by "children".

-Posted by Frosty on December 16, 2003 10:49 AM

Normal Guy

r ur pics copyrighted?

-Posted by as on July 23, 2004 12:08 AM

Normal Guy

can i use your pic. of meatwad for an icon and for a paper on modern cartoons

-Posted by on August 3, 2004 08:59 PM




Comment posting has been turned off because I don't have enough time and will to deal with the constant comment spamming. I'm very sorry and will fix this sometime soon (soon = before 2004 ends).

MovableType AmphetaDesk
NetNewsWire BlogTree Subscribe with Bloglines RSS Feed
Copyright © 2001 - 2003 by Daniel Kapusta