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.   }  
  • 相关阅读:
    MySql入门知识(一)
    一起学Android之Handler
    一起学Android之Http访问
    一起学Android之Sqlite
    一起学Android之Storage
    iOS核心动画高级技巧-1
    iOS界面流畅技巧之微博 Demo 性能优化技巧
    IOS 企业版证书($299)In-House方式发布指南
    App Store生存指南
    企业证书发布APP
  • 原文地址:https://www.cnblogs.com/cxlings/p/2259529.html
Copyright © 2011-2022 走看看