Using Javascript, Jquery preferably, I want to be able to trigger the visiblity of the div when a user is at a certain page height. NYtimes has an example of this when you scroll to the bottom of a story, a slider pops out with another news story, and goes away if you scroll up.
I think the methods you want are:
$(document).scroll() // event triggered whenever the page is scrolled
$(document).height() // gets the height of the entire page
$(window).height() // gets the height of the current window
$(document).scrollTop() // gets the top position currently visible
Using these, you could write a method to show a div when the window is 100 pixels from the bottom:
$(document).scroll(function() {
var scrollBottom = $(document).scrollTop() + $(window).height();
var height = $(document).height();
if (scrollBottom > height - 100)
$("div").show();
else
$("div").hide();
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.