<! Doctype HTML public "-// W3C // dtd xhtml 1.0 strict // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> untitled document </title>
<Style type = 'text/CSS '>
# D {border: 1px solid green; width: 90px; Height: 57px; position: absolute ;}
# H {border: 1px solid green; width: 90px; Height: 17px; position: absolute ;}
</Style>
<SCRIPT type = 'text/JavaScript 'src = "/JS/jquery/jquery-1.2.6.min.js"> </SCRIPT>
<SCRIPT type = 'text/JavaScript '>
(Function ($ ){
$. FN. Extend ({
Drag: function (ID ){
$ (This). mousedown (function (event ){
VaR OBJ, PX, Py;
Document. onmouseup = MUP;
Document. onmousemove = mmove;
Mdown (ID, event );
Function mdown (ID, event ){
OBJ = Document. getelementbyid (ID );
If (obj. setcapture)
OBJ. setcapture ();
Else
Window. captureevents (event. mousemove | event. mouseup );
Px = event. clientx-obj. offsetleft;
Py = event. clienty-obj. offsettop;
}
Function mmove (event ){
If (window. Event) event = Window. event;
If (OBJ ){
OBJ. style. Left = event. clientx-px + "PX ";
OBJ. style. Top = event. clienty-py + "PX ";
}
}
Function MUP (event ){
If (OBJ ){
If (obj. releasecapture)
OBJ. releasecapture ();
Else
Window. captureevents (event. mousemove | event. mouseup );
OBJ = NULL;
}
}
});
}
});
}) (Jquery );
</SCRIPT>
</Head>
<Body>
<Div id = "D">
<Div id = "H"> header </div>
</Div>
<SCRIPT type = 'text/JavaScript '>
$ ("# H"). Drag ('D'); // under IE, click id = 'H' to drag id = 'D', FF compatibility to be improved
</SCRIPT>
</Body>
</Html>