I'm seeking to understand the code and function(s) that determines when a particular part of a webpage has been viewed (for mere understanding).
For example, on the Stack Exchange web sites, it determines when a person has fully read the "about" page (and awards a badge for such). What function/code/language is watching for this?
Or at least, how could I trace and/or determine where this function is in a page's source?
You can use JavaScript to detect how far a user has scrolled on the page, and if they've scrolled past a certain point (say 80% of the article) you can fire off an AJAX request which logs that the user has scrolled past that point.
Quick example in jQuery:
$('body').scroll(function () {
if($(this).scrollTop() > 1000) {
// Fire off AJAX request
}
});
Didn't test that, and you'll want to change 1000 to be the amount of pixels until you get to an element in the article so it works for different article lengths.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With