niche Posted February 16, 2012 Share Posted February 16, 2012 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 More sharing options...
ShadowMage Posted February 16, 2012 Share Posted February 16, 2012 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 More sharing options...
niche Posted February 16, 2012 Author Share Posted February 16, 2012 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 More sharing options...
ShadowMage Posted February 16, 2012 Share Posted February 16, 2012 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 More sharing options...
niche Posted February 19, 2012 Author Share Posted February 19, 2012 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.