how to get anchor.x/y

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mark

    how to get anchor.x/y

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

    Why not or how come?

    TIA
    Mark
  • Matt Kruse

    #2
    Re: how to get anchor.x/y

    "Mark" <alpha@kcbbs.ge n.nz> wrote:[color=blue]
    > I cannot read the x and y properties of the anchor object.
    > The object is valid.[/color]

    I have a lib whose only purpose is to get the coordinates of an anchor. You
    might find it useful:


    Hope that helps!

    Matt


    Comment

    • Michael Winter

      #3
      Re: how to get anchor.x/y

      Mark wrote on 18 Dec 2003 at Thu, 18 Dec 2003 03:46:07 GMT:
      [color=blue]
      > I cannot read the x and y properties of the anchor object.
      > The object is valid.
      >
      > Why not or how come?[/color]

      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.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk")

      Comment

      Working...