[ACCEPTED]-Javascript mechanism to autoscroll to the bottom of a growing page?-scroll
Accepted answer
x = 0; //horizontal coord
y = document.height; //vertical coord
window.scroll(x,y);
0
To scroll the whole document use this:
window.scrollTo(0, document.body.scrollHeight);
if 2 you have just a single scrollable div or 1 something then the process is different:
var obj = $('id');
obj.scrollTop = obj.scrollHeight;
for (i = 0; i < 100; i++) {
document.write("" + i + "<br />");
window.scroll(0,document.body.offsetHeight);
}
0
Nice jQuery function gets this done
$('html,body').animate({ scrollTop: element.offset().top }, 'slow');
This 2 worked for me, used it to AutoScroll to 1 a dropdown menu to bring it into focus
This Explains What set time interval is 3 - http://www.w3schools.com/jsref/met_win_setinterval.asp
This Explains What set time out is - http://www.w3schools.com/jsref/met_win_settimeout.asp
This 2 will scroll the page with javascript and 1 will stop after 6 seconds
<script type = "text/javascript" >
var x;
function autoscroll(){
self.scrollBy(0,x)
}
function playautoscroll(){
x = 1;
setInterval('autoscroll()',0.01);
stop();}
function onetozero(){
x=0;
}
function stop(){
setTimeout ("onetozero()",6000);
}
window.onload=playautoscroll
</script>
obj.scrollTop = obj.scrollHeight;
0
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.