Jump to content

measuring how far down a page a user is browsing-Solved with thanks


niche

Recommended Posts

Is there a way to tell how far down a page someone's browsing (without clicking on something)? If so, what are some keywords to get me started?

Link to comment
Share on other sites

http://w3schools.com...pagexoffset.asp That should get you started. I think there is also an onscroll event that you can attach to the body or window to use for checking these properties. EDIT: Here's the MDN reference for onscroll:https://developer.mozilla.org/en/DOM/window.onscroll It doesn't say anything about browser support, though, so you might want to do a little more research/testing.
Link to comment
Share on other sites

Thanks ShadowMage. How would you save the data from the scroll down without clicking or inputting? The only way know how to get JS var data into a mysql database is by create an XMLHttpRequest object, but that doesn't seem appropriate in this situation. Is there another way? If so, what do you suggest?

Link to comment
Share on other sites

AJAX is the only way that I know of, too. It would definitely not be appropriate to send and AJAX request in the onscroll event. That would generate a lot of requests. What you could do is set up a timer that would get the current scroll position and send it to the database. This timer could run every 2-3 seconds (every second might be a bit much).

Link to comment
Share on other sites

Well said. I'll bet I could also use an if statement that trips after enough scroll down. I just needed some help with an approach. Thanks again ShadowMage.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...