首页 > Web开发 > 详细

js scrollTop, 滚动条操作

时间:2016-03-13 23:56:53      阅读:485      评论:0      收藏:0      [点我收藏+]
设置页面加载时滚动条自动滚到底的方法:

jQuery:


复制代码 代码如下:


 $(function(){
   var h = $(document).height()-$(window).height();
   $(document).scrollTop(h);
 });



JavaScript:


复制代码 代码如下:


 window.onload = function(){
   var h = document.documentElement.scrollHeight || document.body.scrollHeight;
   window.scrollTo(h,h);
 }

<button onclick="text1.scrollTop=text1.scrollHeight">滚动</button><br>

cache the xmlhttprequest instance, if you want to use setinterval or settimeout. or, there might be a memory leap.

  

js scrollTop, 滚动条操作

原文:http://www.cnblogs.com/hualiu0/p/5274037.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!