Identifying the uppermost object visible at top of page while scrolling

C

craigslist.jg

Is this possible?

+--------------------------------
| * here
|
|
|
|
|
|
+--------------------------------

Say the above is a webpage, and I'm halfway through scrolling the
page. Is it possible, as you scroll to identify when the "here" object
comes into view? Let's say I know that the object is a <div> that
takes up 100% of the page.

Thanks!
 
T

Thomas 'PointedEars' Lahn

Is this possible?

Is what possible? (Don't assume that people read the Subject header first.)
Say the above is a webpage, and I'm halfway through scrolling the
page. Is it possible, as you scroll to identify when the "here" object
comes into view?

It is, to a certain extent. You can determine the offset position of an
element by recursively adding up the values of the proprietary `offsetLeft'
and `offsetTop' properties of the corresponding DOM object each. You can
determine the scrolling position by evaluating the proprietary `scrollLeft'
and `scrollTop' properties of the HTMLHtmlElement (document.documentElement)
or the HTMLBodyElement (document.body) object. You can listen to scroll
events, keyboard events and mouse events to execute code when the document
was scrolled.


HTH

PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top