1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
var z=1
var dragobject={
x:0, y:0, offsetx:null,offsety:null,targetobj:null,dragapproved:0,
initialize:function(){
document.onmousedown=this.drag
document.onmouseup=function(){this.dragapproved=0; this.targetobj.style.zIndex=z++;}}
,drag:function(e){
var evtobj=window.event? window.event:e
this.targetobj=window.event? event.srcElement:e.target
while (this.targetobj.className!="drag" && this.targetobj.tagName!="BODY") this.targetobj=this.targetobj.parentNode
if (this.targetobj.className=="drag"){
this.dragapproved=1;
this.targetobj.style.zIndex='999'
if (isNaN(parseInt(this.targetobj.style.left))){this.targetobj.style.left=0}
if (isNaN(parseInt(this.targetobj.style.top))){this.targetobj.style.top=0}
this.offsetx=parseInt(this.targetobj.style.left)
this.offsety=parseInt(this.targetobj.style.top)
this.x=evtobj.clientX
this.y=evtobj.clientY
if (evtobj.preventDefault) evtobj.preventDefault()
document.onmousemove=dragobject.moveit}} |