This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes calculate object position to the top edge of the browser Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "calculate object position to the top edge of the browser" Watch "calculate object position to the top edge of the browser" New topic
Author

calculate object position to the top edge of the browser

david arnold
Ranch Hand

Joined: Apr 10, 2009
Posts: 129
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

Joined: Mar 21, 2003
Posts: 1049
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

Joined: Apr 10, 2009
Posts: 129
Got it, thank you. I will check it.

Regards,
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: calculate object position to the top edge of the browser
 
Similar Threads
Controlling DIV and/or TR height
a little math ...
JTextArea row height
Measure distance between two cities ?
how to use distanceBetween built in methog