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.
views:
28answers:
1
+1
A:
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();
});
David Fullerton
2010-05-07 02:43:38
looks good i will try it!
james
2010-05-07 20:46:50