To zwykły drag&drop z pewnym 'dodatkiem' jakim jest ramka za którą można przeciągać div-a - kilka linijek kodu - kiedyś pisałem(na podstawie innego kodu) własny skrypt, którego jak zwykle nie dokończyłem, ale akurat tamto zrobiłem: zaraz go poprawię i przedstawię tutaj
--edit--
No i już - możliwe, że trochę zbędnego kodu by się znalazło, jakieś błędy i te sprawy, ale działa pod FF3 - w innych nie testowałem, gdyż jak pisałem był to skrypt niedokończony - teraz wywaliłem kilkanaście opcji, żeby to było lekkie
- jak czegoś Ci brakuje to napisz to dopisze może
:
Kod
<html>
<head>
<script>
function dnd(obj,handle){
function init(){
handle.onmousedown = function(e){ dragDrop(obj,e); }
obj.onselectstart = function(){return false;};
obj.unselectable = "on";
obj.style.MozUserSelect = "none";
}
function dragDrop(o,e,x,y){
e = e || e.event;
if(document.last) document.last.style.zIndex = 1;
with(document.last = o){
e = e || e.event;
o.style.zIndex = 10;
x = ~~(e.layerX || e.offsetX);
y = ~~(e.layerY || e.offsetY);
}
document.onmousemove = function(e){
e = e || e.event;
document.last.style.left = e.clientX - x;
document.last.style.top = e.clientY - y;
return false;
}
document.onmouseup = function(){
this.onmousemove = null;
}
}
init();
}
window.onload = function(){
dnd(document.getElementById('test1'),document.getElementById('handle1'));
dnd(document.getElementById('test2'),document.getElementById('handle2'));
}
</script>
<style>
div{ position: absolute; width: 100px; height: 100px; border: 1px solid black;}
#handle1,#handle2 { text-align: center; width: 80%; height: 30px; top: 5%; left: 10%; background-color: white;}
</style>
</head>
<body>
<div id="test1" style="left: 100px; top:100px; background-color: brown;"><div id="handle1">Handle</div</div>
<div id="test2" style="left: 300px; top:300px; background-color: red;"><div id="handle2">Handle</div></div>
</body>
</html>