Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calculate object position to the top edge of the browser

 
david arnold
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am wondering if I could calculate the distance between an object and the top edge of the browser using javascript?

This method ( getposOffset(obj, "top") ) return the absolute height of the object on the page, but I want to know the height of the object to the top edge, not top of the page. As I scroll down, the height/distance between the object and the edge keep changes, that is what I need to know.

Thanks.
 
Chris Baron
Ranch Hand
Posts: 1061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At the bottom of this page is a sample script on how to get window.pageYOffset, document. body.scrollTop or document.documentElement.scrollTop.
Not tested, just googled it.
 
david arnold
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it, thank you. I will check it.

Regards,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic