Table row offsetTop bug in Safari
I found what seems to be a bug in the Safari web browser recently. The problem occurs when there is a table, and you are trying to find the offsetTop property of a row in that table. I have an example that illustrated the problem when in Safari.
Jacob,
Thanks for the post confirming the same results that I have found.
I found that basically none of the offset properties work, offsetWidth, offsetHeight, offsetTop etc. None work for a TR.
I did find a workaround to this problem for Safari. The offsetTop can be found by examining the trElement.firstChild (which is a TD) if it exists. The TD contains the offset for the TR.
I found the width of the row by doing this:
offsetWidthTR = trElement.lastChild.offsetLeft + trElement.lastChild.offsetWidth;
So basically you have to look at the first cell and the last cell and obtain that info down.
My GetPageYCoordinate and GetPageXCoordnate methods which drill up to the using the offsetParent from the element passed in has the special case for handling the TR when the browser is Safari.
At any rate, thanks for confirming my suspicions which lead to my answer.
Comment by Steve West — 9/7/2006 #
I just checked this bug again with the new Safari 3 beta, and it seems to be fixed.
Comment by site admin — 6/12/2007 #
The same issue occurs for me, even i use safari 3.0.2
Comment by arun — 8/23/2007 #
[...] in the source to JBoss Richfaces. The blog post that was referenced was a small note I made about bug in the Safari web browser. They provided a workaround in Javascript code for a suggestion box, and they referenced my post in [...]
Pingback by Jacob’s Technical Blog » My blog post found in JBoss Richfaces source — 12/9/2007 #
I did find a workaround to this problem for Safari. The offsetTop can be found by examining the trElement.firstChild (which is a TD) if it exists. The TD contains the offset for the TR.
Thanks Steve. I had almost given up until I landed here. trElement.firstChild solved my problem for finding offsetTop value in Safari(v2.0). Even this works in Mozilla(v5.0) and IE6 too.
Thanks a lot once again
Comment by Shalabh — 4/18/2008 #