可動サスペンションDIVの作成

1614 ワード

HTML    :




   var divObj=null;
   var pX;
   var pY;
   document.onmousemove = divMove;
   document.onmouseup = divUp;
  
   function moveObj(obj){
    divObj=document.all(obj);
    pX = divObj.style.pixelLeft-event.x;
    pY = divObj.style.pixelTop-event.y;
   } 
   function divMove(){
   if(divObj){
      divObj.style.left = pX+event.x;
      divObj.style.top = pY+event.y;
      event.returnValue = false;
   }
   }
   function divUp(){
   if(divObj){
      divObj=null;
   }
   }


Moving DIV