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.
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.
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.
[...] 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 [...]
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
5 Comments
Steve West
September 7th, 2006 at 7:34 pm
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.
site admin
June 12th, 2007 at 11:12 am
I just checked this bug again with the new Safari 3 beta, and it seems to be fixed.
arun
August 23rd, 2007 at 12:47 am
The same issue occurs for me, even i use safari 3.0.2
Jacob’s Technical Blog » My blog post found in JBoss Richfaces source
December 9th, 2007 at 2:30 am
[...] 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 [...]
Shalabh
April 18th, 2008 at 12:04 am
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