
|
浏览:4852008-03-20 14:18 来自!天山寒雪 :
=====这是里面的 拖动代码,但是不兼容 FF, 谁能把里面 改一下,让他兼容FF var Dragdrop=new Class(); Dragdrop.prototype= { initialize:function(width,height,shadowWidth,showShadow,contentType) { this.dragData=null; this.dragDataIn=null; this.backData=null; this.width=width; this.height=height; this.shadowWidth=shadowWidth; this.showShadow=showShadow; this.contentType=contentType; this.IsDraging=false; this.oObj=G('dialogBox'); Event.observe(G('dialogBoxTitle'),"mousedown",this.moveStart.bindAsEventListener(this),false) } ,moveStart:function(event) { this.IsDraging=true; if(this.contentType==1) { G("iframeBG").style.display=""; G("iframeBG").style.width=this.width; G("iframeBG").style.height=this.height }; Event.observe(document,"mousemove",this.mousemove.bindAsEventListener(this),false); Event.observe(document,"mouseup",this.mouseup.bindAsEventListener(this),false); Event.observe(document,"selectstart",this.returnFalse,false); this.dragData= { x:Event.pointerX(event),y:Event.pointerY(event) }; this.backData= { x:parseInt(this.oObj.style.left),y:parseInt(this.oObj.style.top) } } ,mousemove:function(event) { if(!this.IsDraging)return; var iLeft=Event.pointerX(event)-this.dragData["x"]+parseInt(this.oObj.style.left); var iTop=Event.pointerY(event)-this.dragData["y"]+parseInt(this.oObj.style.top); if(this.dragData["y"]<parseInt(this.oObj.style.top))iTop=iTop-12; else if(this.dragData["y"]>parseInt(this.oObj.style.top)+25)iTop=iTop+12; this.oObj.style.left=iLeft; this.oObj.style.top=iTop; if(this.showShadow) { G('dialogBoxShadow').style.left=iLeft+this.shadowWidth; G('dialogBoxShadow').style.top=iTop+this.shadowWidth }; this.dragData= { x:Event.pointerX(event),y:Event.pointerY(event) }; document.body.style.cursor="move" } ,mouseup:function(event) { if(!this.IsDraging)return; if(this.contentType==1)G("iframeBG").style.display="none"; document.onmousemove=null; document.onmouseup=null; var mousX=Event.pointerX(event)-(document.documentElement.scrollLeft||document.body.scrollLeft); var mousY=Event.pointerY(event)-(document.documentElement.scrollTop||document.body.scrollTop); if(mousX<1||mousY<1||mousX>document.body.clientWidth||mousY>document.body.clientHeight) { this.oObj.style.left=this.backData["x"]; this.oObj.style.top=this.backData["y"]; if(this.showShadow) { G('dialogBoxShadow').style.left=this.backData.x+this.shadowWidth; G('dialogBoxShadow').style.top=this.backData.y+this.shadowWidth } }; this.IsDraging=false; document.body.style.cursor=""; Event.stopObserving(document,"selectstart",this.returnFalse,false) } ,returnFalse:function() { return false } };
楼主
|