how to get anchor.x/y

M

Mark

I cannot read the x and y properties of the anchor object.
The object is valid.

Why not or how come?

TIA
Mark
 
M

Michael Winter

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top