[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 525
  • Last Modified:

Wrong value of cellIndex returned for a cell that has "display:none" style applied


I'm using IE 6.0 on WinXp SP2 , using JavaScript.

I iterate over the cells in a row in html table , and check
for the cellIndex of each cell .

First cell  (index:0 ) in the row has the "display:none" style .

For some reason (another cool and stupid feature ???  )
I get for this cell wrong value of cellIndex ( it's actually seems like it returns the last index in this row.  For ex. if I have 3 cells in the row , then I get the value 2 for this cell )

For the second cell in the same row I get value of "0" , and for the last I get "1" .

So it seems that if a cell has "display:none" style applied , it's cellIndex property get the value of  last index in the row.

When I remove the "display:none" style from the cell , I get the cellIndex values right . ( 0,1,2).

Though when I access the first cell ( even when it has "display:none" style)
 using the oRow.cells[0] , I get the right cell .

Mystery / Bug / (stupid) Feature ????

  • 3
  • 2
1 Solution
It's a bug in IE.

Here are the specs from MS:
>> Retrieves the position of the object in the cells collection of a row.

Here are the specs from W3C:
>> The index of this cell in the row, starting from 0. This index is in document tree order and not display order.

The 2 reference agree it should return the index in the document tree.
MS reference does not mention that bug... but it's a bug.
VoidPointerAuthor Commented:
Well .. yeah - it seems so .
I just wanted to be sure whether it's really a bug .
Since I couldn't actually find anything on the web that says it's a known bug ,
including MSDN.

Since the strange thing is that the cells collection returns the right cells ( if accessing it
in the row.cells[i] manner) ,
but the cellIndex attribute is affected by the "display:none" style .

Thanks .

(I just want to see some more replies on this issue - wonder if anyone else encountered this)
I found this article:  http://www.kbalertz.com/kb_Q814506.aspx
(written in 2003)
> Microsoft recommends that you wait for the next Internet Explorer 6 service pack that contains this fix.
Do you have the last version of IE?  If so, MS is not quick at fixing bugs.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Can you show your code?
VoidPointerAuthor Commented:
GrandSchtroumpf : Thank you very much for the help .
It seems that I just haven't searched deep enough on the web for this issue :)

I actually don't have the latest SP for the IE , but anyway I'm not going to use the cellIndex property , since we have many clients with different IE versions .

(I've solved my problem in other way - since my table is dynamically rendered to the client from ASP.NET code , I've just added another attribute to each cell , which holds the REAL cell index as I need it )

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now