< Script >
Function Objectdrapdrop (OBJ ){
VaR Me = This ;
This . Foo = ( Typeof OBJ = ' String ' ) ? Document. getelementbyid (OBJ): OBJ;
This . Foo. onmousedown = Function (E ){
VaR Foo = Me. Foo;
E = E | Event;
If (E. layerx ){
Foo. ooffset = {X: E. layerx, Y: E. layery };
} Else {
Foo. ooffset = {X: E. offsetx, Y: E. offsety };
}
Document. onmousemove = Me. Drag;
Document. onmouseup = Me. Drop;
Document. onselectstart = Function (){ Return False ;}
}
This . Drag = Function (E ){
VaR Foo = Me. Foo;
E = E | Event;
Foo. style. Top = E. clienty + (Document.doc umentelement. scrolltop | Document. Body. scrolltop) - Foo. ooffset. Y + ' Px ' ;
Foo. style. Left = E. clientx + (Document.doc umentelement. scrollleft | Document. Body. scrollleft) - Foo. ooffset. x + ' Px ' ;
}
This . Drop = Function (E ){
E = E | Event;
Document. onmousemove = Document. onmouseup = Document. onselectstart = Null ;
}
}
Window. onload = Function (){
VaR Test1 = New Objectdrapdrop ( ' Foo ' );
}
</ Script >
</ Head >
< Body >
< Div ID = "Foo" > This is a div! </ Div >
</ Body >
I don't really mean much. I didn't understand some things in the same way.