Here is a temporary URL:
http://24.171.2.56:8080/examples/dragDrop.jsp
And here is the properly formatted code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=windows-1252">
<title>Dragging</title>
<script type="text/javascript">
var Drag = {
obj : null,
init : function(o) {
o.onmousedown = Drag.start;
o.onDragEnd = new Function();
},
start : function(e) {
e = Drag.fixE(e);
var o = Drag.obj = this;
o.lastMouseX = e.clientX;
o.lastMouseY = e.clientY;
document.onmousemove = Drag.drag;
document.onmouseup = Drag.end;
return false;
},
drag : function(e) {
e = Drag.fixE(e);
var o = Drag.obj;
var newX = parseInt(o.style.left) + e.clientX
- o.lastMouseX;
var newY = parseInt(o.style.top) + e.clientY
- o.lastMouseY;
Drag.obj.style.left = newX + "px";
Drag.obj.style.top = newY + "px";
Drag.obj.lastMouseX = e.clientX;
Drag.obj.lastMouseY = e.clientY;
return false;
},
end : function(e) {
e = Drag.fixE(e);
document.onmousemove = null;
document.onmouseup = null;
Drag.obj.onDragEnd(e.clientX, e.clientY);
Drag.obj = null;
},
fixE : function(e) {
if (typeof e == 'undefined') e = window.event;
return e;
}
};
</script>
<style type="text/css">
div.container { background-color: #bbb; position: absolute;
width: 100px; height: 200px; top: 50px; }
div.container h1 { cursor: move; }
div.container p.field { background-color: #eee;
border: 1px solid black; padding: 0 0.5ex;
position: relative; }
div#one { left: 50px; }
div#two { left: 250px; }
</style>
</head>
<body>
<div class="container" id="one">
<h1>
One
</h1>
<p class="field" id="harry" style="left: 0; top: 0;">Harry</p>
</div>
<div class="container" id="two">
<h1>
Two
</h1>
</div>
<div id="test" style="cursor: pointer; position: relative; top: 0; left:
0;">
test
</div>
<script type="text/javascript">
var two = document.getElementById("two");
var test = document.getElementById("test");
Drag.init(test);
var harry = document.getElementById("harry");
Drag.init(harry);
harry.onDragEnd = function(x, y) {
two.appendChild(harry);
harry.style.top = "0";
harry.style.left = "0";
}
</script>
</body>
</html>