本帖最后由 qq272627363 于 2012-10-18 20:27:33 编辑

解决方案 »

  1.   

    参数jQuery的Draggable
      

  2.   


    <script>
    /**
    **@author lonephoenix
    **/
    var Drag=function(obj) {
      var x,y,ox,oy;
      var nx,ny;
      var objmove=new Boolean(false);
      obj.onmousedown=function(e) {
        e=e||event;
    if(e.button==0) {
    obj.style.cursor="move";
    ox=obj.offsetLeft;
        oy=obj.offsetTop;
        x=e.clientX;
        y=e.clientY;
    objmove=true;
    };
      };
      obj.onmousemove=function(e) {
        e=e||event;
        if(objmove==true) {
    nx=ox+e.clientX-x;
    ny=oy+e.clientY-y;
    obj.style.left=nx+"px";
    obj.style.top=ny+"px";
    }
      };
      obj.onmouseup=function(e) {
        e=e||event;
        if(e.button==0) {
        objmove=false;
    obj.style.cursor="default";
    }
      };
    };
    window.onload=function() {
    var oDiv=document.getElementsByTagName("div")[0];
    Drag(oDiv);
    }