zoukankan      html  css  js  c++  java
  • js 鼠标双击滚动单击停止

    <!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>
    人如代码,规矩灵活;代码如诗,字句精伦。
  • 相关阅读:
    DockerFile构建镜像
    docker基本命令
    docker持久化
    JS 中 this 指向问题
    解决"/usr/local/bin/dockercompose: Permission denied"问题
    docker配置国内镜像
    docker网络
    国内常用镜像地址
    Visual Studio中快捷键收缩和展开代码段方法
    STM32中关于RCC时钟的理解
  • 原文地址:https://www.cnblogs.com/xinlinux/p/4220918.html
Copyright © 2011-2022 走看看