• 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.   }  
  • 相关阅读:
    c++常用库
    boost
    android
    UITableView 多选
    c++ 比较两个集合
    事件加不上的另一种原因
    ios多线程
    ubuntu android
    jna StdCallCallback 回调问题查证
    java
  • 原文地址:https://www.cnblogs.com/cxlings/p/2259529.html
Copyright © 2020-2023  润新知