window.scrollTo(0,document.body.scrollHeight);
// To scroll to the bottom of a div
const theElement = document.getElementById('elementID');
const scrollToBottom = (node) => {
node.scrollTop = node.scrollHeight;
}
scrollToBottom(theElement); // The specified node scrolls to the bottom.
// without smooth-scroll
const scrollToBottom = () => {
divRef.current.scrollTop = divRef.current.scrollHeight;
};
//with smooth-scroll
const scrollToBottomWithSmoothScroll = () => {
divRef.current.scrollTo({
top: divRef.current.scrollHeight,
behavior: 'smooth',
})
}
scrollToBottom()
scrollToBottomWithSmoothScroll()
function gotoBottom(id){
var element = document.getElementById(id);
element.scrollTop = element.scrollHeight - element.clientHeight;
}
window.onscroll = function(ev) {
if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
// you're at the bottom of the page
}
};
var notChangedStepsCount = 0;
var scrollInterval = setInterval(function() {
var element = document.querySelector(".element-selector");
if (element) {
// element found
clearInterval(scrollInterval);
element.scrollIntoView();
} else if((document.documentElement.scrollTop + window.innerHeight) != document.documentElement.scrollHeight) {
// no element -> scrolling
notChangedStepsCount = 0;
document.documentElement.scrollTop = document.documentElement.scrollHeight;
} else if (notChangedStepsCount > 20) {
// no more space to scroll
clearInterval(scrollInterval);
} else {
// waiting for possible extension (autoload) of the page
notChangedStepsCount++;
}
}, 50);
function scrollToBottom() {
const scrollingElement = document.scrollingElement || document.body
scrollingElement.scrollTop = scrollingElement.scrollHeight
}
window.scrollBy(0,document.body.scrollHeight);