zoukankan      html  css  js  c++  java
  • js 捕获鼠标事件

    1. function drag(overFlow,title){   
    2.         title.onmousedown = function(evt){   
    3.             var doc = document;   
    4.             var evt = evt || window.event;   
    5.             var x = evt.offsetX?evt.offsetX:evt.layerX;   
    6.             var y = evt.offsetY?evt.offsetY:evt.layerY;   
    7.             if(overFlow.setCapture){   
    8.                 overFlow.setCapture();   
    9.             }else if(window.captureEvents){   
    10.                 window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);   
    11.             }   
    12.   
    13.             doc.onmousemove = function(evt){   
    14.                 evt = evt || window.event;   
    15.                 var xPosition = evt.pageX || evt.clientX;   
    16.                 var yPosition = evt.pageY || evt.clientY;   
    17.                 var newX = xPosition - x;   
    18.                 var newY = yPosition - y;   
    19.                 overFlow.style.left = newX;   
    20.                 overFlow.style.top =  newY;   
    21.             };   
    22.   
    23.             doc.onmouseup = function(){   
    24.                 if(overFlow.releaseCapture){   
    25.                     overFlow.releaseCapture();   
    26.                 }else if(window.captureEvents){   
    27.                     window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);   
    28.                 }   
    29.                 doc.onmousemove=null;   
    30.                 doc.onmouseup=null;   
    31.             };   
    32.         };   
    33.   }  
  • 相关阅读:
    在Fragment中保存WebView状态
    Code First下迁移数据库更改
    脚本解决.NET MVC按钮重复提交问题
    1.1C++入门 未完待续。。。
    0.0C语言重点问题回顾
    12F:数字变换
    12G:忍者道具
    12D:迷阵
    12C:未名冰场
    12B:要变多少次
  • 原文地址:https://www.cnblogs.com/cxlings/p/2259529.html
Copyright © 2011-2022 走看看