日期:2014-05-16 浏览次数:20498 次
<div style="height:600px;width:100%;overflow:hidden;line-height:20px;" id="dvScroll" onmouseover="clearInterval(timer);" onmouseout="timer = setInterval(scrollDiv, 100);">
<div id="dvContent">内容<br />内容<br />内容<br />内容<br />内容</div></div>
<script>
var scrollTop = 0, timer, dvScroll,containerHeight, scrollHeight, lineheight = 20;
function scrollDiv() {
scrollTop += 5;
if (scrollTop > scrollHeight) scrollTop = scrollHeight;
dvScroll.scrollTop = scrollTop;
if (scrollTop == scrollHeight) {//完成滚动,要ajax重新获取内容或者刷新页面都行,下面为重新加载的,要ajax自己取消注释,导入jquery
clearInterval(timer);
window.location.reload();
/*//ajax动态加载部分,用了jquery
$('#dvContent').load('内容页url地址',function(){
dvScroll.scrollTop = scrollTop = 0;//重置滚动高度
scrollHeight =containerHeight + dvContent.offsetHeight;
timer = setInterval(scrollDiv, 100);
});
*/
&n