yambbkru,
Вариант...
<html>
<head>
</head>
<body>
<script type="text/javascript" charset="utf-8">
var DragObject;
var OffsetX, OffsetY;
var isDragging = false;
window.onload = function(e) {
var o = document.getElementById("obj01");
o.onmousedown = function (event)
{
mouseDown(o, event);
}
o.style.position = "relative";
o.style.left = "0px";
o.style.top = "0px";
}
function mouseDown(o, e) {
DragObject = o;
DragObject.ondrag = function() {return false;}
DragObject.onselectstart = function() {return false;}
if (window.event) {e = window.event;}
var oX = parseInt(DragObject.style.left);
var oY = parseInt(DragObject.style.top);
var mouseX = e.clientX;
var mouseY = e.clientY;
OffsetX = mouseX - oX;
OffsetY = mouseY - oY;
isDragging = true;
return false;
}
document.onmousemove = function (e) {
if (!isDragging) {return;}
if (window.event) {e = window.event;}
var mouseX = e.clientX;
var mouseY = e.clientY;
var newX = mouseX - OffsetX;
var newY = mouseY - OffsetY;
DragObject.style.left = newX + "px";
DragObject.style.top = newY + "px";
return false;
}
document.onmouseup = function() {
if (!isDragging) {return;}
isDragging = false;
return false;
}
</script>
<input type="button" id="obj01" >
</body>
</html>