By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,930 Members | 1,492 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,930 IT Pros & Developers. It's quick & easy.

how to get anchor.x/y

P: n/a
I cannot read the x and y properties of the anchor object.
The object is valid.

Why not or how come?

TIA
Mark
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Mark" <al***@kcbbs.gen.nz> wrote:
I cannot read the x and y properties of the anchor object.
The object is valid.


I have a lib whose only purpose is to get the coordinates of an anchor. You
might find it useful:
http://www.mattkruse.com/javascript/anchorposition/

Hope that helps!

Matt
Jul 20 '05 #2

P: n/a
Mark wrote on 18 Dec 2003 at Thu, 18 Dec 2003 03:46:07 GMT:
I cannot read the x and y properties of the anchor object.
The object is valid.

Why not or how come?


It is usually a good idea to provide more information than that
above.

In the future, please include the following:

1) A relavant code example. In this case, the object and the
properties or methods you used to get the values
2) The browser, version and platform that you used to test your code
3) What values you did get and what you expected (not relavant in
this case)

This helps to rule out any syntax errors you made, or any known
issues with that browser.

In this instance, it's probably because you're trying to use a
property not supported by your browser. Try this:

if (obj.x && obj.y) {
// Use the .x and .y properties
} else if (obj.offsetLeft && obj.offsetTop) {
// Use the .offsetLeft and .offsetTop properties
}

where obj is the anchor object you're checking.

Be aware that the numbers returned may change in different browsers.
For example:

<DIV style="margin-top: 50px">
<A ...>...</A>
</DIV>

In Opera, the values returned were x=8, y=58.
In IE, the values were x=0, y=50.

Depending upon how you use the values, this may result in minor
errors.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk")
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.