473,320 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Safari offsetParent/offsetLeft Problem!

I've got a script that determines the true position of an element in
the page by cycling up the .offsetParent elements all the way up to the
<body> element and tallying up the .offsetLeft values returned by each
element. It works fine on the major browsers (IE, Moz, NS) on PC but
Safari on the Mac returns "0" for the offsetLeft right off the body tag
when it should be a greater value than that.
Anybody already deal with this?

Thank you in advance!
Ara

Jul 23 '05 #1
3 7587


ar*************@gmail.com wrote:
I've got a script that determines the true position of an element in
the page by cycling up the .offsetParent elements all the way up to the
<body> element and tallying up the .offsetLeft values returned by each
element. It works fine on the major browsers (IE, Moz, NS) on PC but
Safari on the Mac returns "0" for the offsetLeft right off the body tag
when it should be a greater value than that.


You should not stop at the <body> element but walk up offsetParent till
it is null. Perhaps with Safari the <html> element adds an offset. Just
a guess however, I haven't looked into that with Safari now.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
Hi Martin,

Thanks for the reply. The thing is, I was using .parentNode to cycle
through all the elements but that was returning very strange results
since not all parent nodes affected the offset of their children.
However by using .offsetParent I was able to get only those who
affected the offset of their children. I say this because using the
..parentNode method, I was able to get all the way up past the <body>,
past <html> all the way to <#document>. But this way I can't.

Besides, I don't even think it would help since Safari reports the
offset differently than IE, Mozilla and NS using the same code. :-(

Ara

Jul 23 '05 #3
ar*************@gmail.com wrote:
Hi Martin,

Thanks for the reply. The thing is, I was using .parentNode to cycle
through all the elements but that was returning very strange results
since not all parent nodes affected the offset of their children.
However by using .offsetParent I was able to get only those who
affected the offset of their children. I say this because using the
..parentNode method, I was able to get all the way up past the <body>,
past <html> all the way to <#document>. But this way I can't.

Besides, I don't even think it would help since Safari reports the
offset differently than IE, Mozilla and NS using the same code. :-(


Have you had a look here?

<URL:http://www.quirksmode.org/index.html?/viewport/compatibility.html>

It's not specific to Safari, but it offers some good tips and hints.

--
Fred
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Saqib Ali | last post by:
Please excuse me, this is a fairly involved question that will likely require you to save the file below to a file and open it in a browser. I use Mozilla 1.5, so the problem I describe below...
1
by: Vittore Zen | last post by:
Hi, a little question. I have some nested tables with some divs (so default set is relative - ok?) Now, i need to draw a line from one div to another. The problem is to find the position of...
1
by: Roger | last post by:
I am trying to capture the image coordinates when a user clicks on an image. My code is working in Firefox, Mozilla, Netscape, IE, and Opera, but fails under Konqueror (and I suspect Safari). ...
12
by: cewisham | last post by:
I have a menu that pops up different layers as you mouse over. Seems to work OK in IE 6. I position the layers dynamically with javascript because the menu moves when users resize their browser...
2
by: amattie | last post by:
Anyone know what the specific difference is between the offsetParent and parentNode properties of a DOM element are? Mozilla's docs on the DOM element...
5
by: webEater | last post by:
In XHTML mode (application/xhtml+xml) Firefox does not know offset properties (offsetParent/Left/Top). In all the other browsers it works. Does someone has the same problem or knows a solution for...
1
by: Orion | last post by:
In my code i am trying to access offsetLeft and offsetTop values for a element which is a div, I use offsetParent property to obtain the same. The code i use is this.tip.style.left =...
1
by: Fabian Lenzen | last post by:
Hi, I’m creating a web application using XUL and SVG. My problem: I’ve tried to draw for example a dot where the user clicks in the SVG area. I get the clientX/Y-data of the event, but I also...
1
by: thirunavukarasukm | last post by:
Hai: Define offsetParent? what is neccessary offsetTop and offsetLeft
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.