#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Posts
    8
    Rep Power
    0

    How to get the visible document absolute position in javascript?


    I want to know the absolute position of the portion of the document that is currently visible in the browser. In other words, if the user has scrolled down or across in the document, I would like to get the absolute position of the upper left corner of the visible portion of the document.

    I've tried document.body.clientX and document.body.offsetX, but neither seems to give an absolute position, only a relative position. Does anyone have any other suggestions?
  2. #2
  3. No Profile Picture
    Senior Citizen
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2001
    Location
    leftcoast
    Posts
    2,019
    Rep Power
    16
    IE: document.body.scrollTop
    NS/mozilla: window.pageYOffset
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Location
    singapore
    Posts
    16
    Rep Power
    0
    scrollX, scrollY for Mozilla.
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Posts
    8
    Rep Power
    0
    Thanks, that's exactly what I was looking for.

    On a somewhat related note, does anyone have a good source that shows the differences in javascript between IE and Mozilla?
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2002
    Location
    Seattle WA
    Posts
    863
    Rep Power
    14
    Not an online source, but Flanagan's book JavaScript: The Definitive Guide is exactly what it advertises. It is the resource for javascript in my opinion, and clearly points out the differences between compliant browsers and Explorer, as well as the early buggier versions of Netscape. This isn't a beginner's book though....
  10. #6
  11. No Profile Picture
    Senior Citizen
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2001
    Location
    leftcoast
    Posts
    2,019
    Rep Power
    16
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    17
    Rep Power
    0
    Another place to get information about cross-browser differences is a good dhtml api (i.e., application programming interface). See a good one that's not too complicated at 13th Parallel . They also have a tutorial on the properties you asked about at viewport

IMN logo majestic logo threadwatch logo seochat tools logo