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>
    人如代码,规矩灵活;代码如诗,字句精伦。
  • 相关阅读:
    Nginx 部署多个 web 项目(虚拟主机)
    Nginx 配置文件
    Linux 安装 nginx
    Linux 安装 tomcat
    Linux 安装 Mysql 5.7.23
    Linux 安装 jdk8
    Linux 安装 lrzsz,使用 rz、sz 上传下载文件
    springMVC 拦截器
    spring 事务
    基于Aspectj 注解实现 spring AOP
  • 原文地址:https://www.cnblogs.com/xinlinux/p/4220918.html
Copyright © 2011-2022 走看看