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.   }  
  • 相关阅读:
    css中position的两种定位(absolute、relative)
    C# 如何转换生成长整型的时间
    C# 如何转换生成长整型的时间
    C# 如何转换生成长整型的时间
    easyui dialog的一个小坑
    easyui dialog的一个小坑
    ACM2027
    [VUE]关于路由哪些事儿
    hexo+github
    我们一起学React Native(一):环境配置
  • 原文地址:https://www.cnblogs.com/cxlings/p/2259529.html
Copyright © 2011-2022 走看看