Alex
Alex

Reputation: 11

Div to open after scrolling to bottom of page

I would like a hidden div to open once the reader has reached the bottom of the page. I found one example that uses ASP and MySQL. Is there a more simple way to do it with JavaScript and div toggle?

Upvotes: 1

Views: 647

Answers (3)

VMAtm
VMAtm

Reputation: 28355

You can try Scroll to top control with some hack.
It has a parameter startline

Integer. Number of pixels from top of doc scrollbar is scrolled before showing control

You can try to set this parameter to the .scrollTop() function, like in other answers:

$(document).height() - $(window).height()

HTH.

Upvotes: 0

Gustav Barkefors
Gustav Barkefors

Reputation: 5086

Well, the post you're referring to has all the JS code necessary for reacting on the user scrolling to the bottom - only, instead of only showing something that was previously hidden, they make a call to the server to fetch more data to display, and that's when ASP and MySQL come into play.

You just need to do

$(window).scroll(function(){
    if  ($(window).scrollTop() == $(document).height() - $(window).height()){
       $('#idOfYourHiddenDiv').show();
    }
});

or something like that (assuming you have jQuery available)

Upvotes: 1

Naoise Golden
Naoise Golden

Reputation: 8913

Maybe the "slider up footer" can help.

Upvotes: 0

Related Questions