How do I scroll near the bottom of a page. I'm using the following code to scroll to the very bottom:
$(document).scrollTop($(document).height());
How do I change this code to scroll near the bottom?
How near?
$(document).scrollTop($(document).height() - 1000);
Will scroll close to the bottom. The problem here is that you have to consider the height of the viewport as well.
A good, cross browser way to get the viewport height is:
var height = Math.max(document.documentElement.clientHeight, window.innerHeight || 0)
then:
var offset = 100;//your offset. 100px from the bottom here
$(document).scrollTop($(document).height() - (height + offset);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments