www.webdeveloper.com
Results 1 to 6 of 6

Thread: how to get the Offset right of an object?

  1. #1
    Join Date
    May 2007
    Posts
    36

    how to get the Offset right of an object?

    Is there a way to find out the "OffsetRight" property of an object? I need to find where the right/top point of my div is. I know OffsetLeft and OffsetTop work but there OffsetRight doesn't exist. One way to find out is to add the OffsetLeft and the width of the div. Only I don't know the width of my div. So how can I find out the offsetRight of my div? Anybody has any ideea?

  2. #2
    Join Date
    Jun 2008
    Location
    England
    Posts
    121
    you can get the width of the div as long as it has been set i believe doing this:

    Code:
    document.getElementById(myDiv).style.width

  3. #3
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    javascript is case sensitive
    offsetLeft, offsetTop, offsetWidth, offsetHeight

    On the other hand, offset position returns a relative value, relative to the object's parent. So my next question is: you need to find the offset position relative to what? To the document (which is known also as absolute position)?
    Last edited by Kor; 06-20-2008 at 06:10 AM.

  4. #4
    Join Date
    May 2007
    Posts
    36
    I have only 1 main div so it's fine. That's not a problem. Problem is in Javascript there is no offsetRight! Only offsetLeft and offsetTop....offsetBottom and offsetRight don't exist.

    I don't know the width of the div, because the text in it changes so it has different widths.

  5. #5
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428

  6. #6
    Join Date
    May 2007
    Posts
    36
    thanks. it worked

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles