码迷,mamicode.com
首页 > Web开发 > 详细

js 鼠标双击滚动单击停止

时间:2015-01-13 13:56:58      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE html>
<html>
 <head> 
  <title>双击滚动代码</title> 
  <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>

 </head> 
 <body> 

 <button id="a1">-</button>
 <input type="number" id="t1" disabled="disabled" value="0" style="text-align:center;">
 <button id="j1">+</button>
 <hr/>
 <hr/>
 <button id="a2">-</button>
 <input type="number" id="t2" disabled="disabled" value="0" style="text-align:center;">
 <button id="j2">+</button>
 
 <div style="height:1500px;">
 </div>
 
    <script>
        
var currentpos,timer;
function initialize()
{
    timer=setInterval("scrollwindow()",3);
}
function sc(){
    clearInterval(timer);
}
function scrollwindow(){
    if(document.body.scrollTop){//加了DTD头时,document.body.scrollTop值始终为0,在此判断一下
        currentpos=document.body.scrollTop;
        window.scroll(0,++currentpos);
            if (currentpos != document.body.scrollTop){
                sc();
            }
    }
    else{
        currentpos=document.documentElement.scrollTop;
            window.scroll(0,++currentpos);
            if (currentpos != document.documentElement.scrollTop){
                sc();
            }
    }
}

document.onmousedown=sc
document.ondblclick=initialize
    
    </script>
 </body>
</html>

 

js 鼠标双击滚动单击停止

标签:

原文地址:http://www.cnblogs.com/xinlinux/p/4220918.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!