Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    pvz
    pvz is offline
    New Coder
    Join Date
    Oct 2003
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Getting the horizontal position of an object..?

    I use...
    document.all[img].offsetTop
    ...to get the verticalposition of an image.
    Q: What do I use to get the horizontal position? I tried what I thought was the obvious:
    document.all[img].offsetLeft
    ...but it didn't work. Hope you can help, thanks/Per

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    object.offsetLeft should work. But be careful, offsetTop and offsetLeft are relative position indicators. If your object is nested, the values are relative to the nesting object.

    How does your object looks like?

    (I suggest you to use document.getElementById(id) method instead of document.all)
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •