##The operating environment of this tutorial: windows7 system, javascript version 1.8.5, DELL G3 computer.How to set the scroll bar position in javascript: 1. Put the vertical scroll bar at the top, the code is [(window.scrollTo(0,0);]]; 2. Put the vertical scroll bar at the bottom, the code is [window .scrollTo(0,document.body.scrollHeight)】.
How to set the scroll bar position in javascript:
JS controls the position of the scroll bar:window.scrollTo(x,y);
document.getElementByIdx_x('textarea').scrollTop = document.getElementByIdx_x('textarea').scrollHeight
function getScrollTop(){ var scrollTop=0; if(document.documentElement&&document.documentElement.scrollTop){ scrollTop=document.documentElement.scrollTop; }else if(document.body){ scrollTop=document.body.scrollTop; } return scrollTop; }
Related free learning recommendations:
The above is the detailed content of How to set scroll bar position in javascript. For more information, please follow other related articles on the PHP Chinese website!