sono ignorante anche io e non ho ben capito che cosa significhi questa riga:
document.onmouseup = new Function("curElement=null")
però credo che proprio li dovresti chiamare una funzione per scrivere un cookie che salvi la posizione
Codice PHP:
var curElement;
function doMouseMove() {
var newleft=0, newTop = 0
if ((event.button==1) && (curElement!=null)) {
newleft=event.clientX-document.all.OuterDiv.offsetLeft-(curElement.offsetWidth/2)
if (newleft<0) newleft=0
curElement.style.pixelLeft= newleft
newtop=event.clientY -document.all.OuterDiv.offsetTop-(curElement.offsetHeight/2)
if (newtop<0) newtop=0
curElement.style.pixelTop= newtop
event.returnValue = false
event.cancelBubble = true
}
}
function doDragStart() {
// Don't do default drag operation.
if ("IMG"==event.srcElement.tagName)
event.returnValue=false;
}
function doMouseDown() {
if ((event.button==1) && (event.srcElement.tagName=="IMG"))
curElement = event.srcElement
}
document.ondragstart = doDragStart;
document.onmousedown = doMouseDown;
document.onmousemove = doMouseMove;
document.onmouseup = salva(el_id);
function salva (id) {
SetCookie(id+"-pos-x",newleft,30);
SetCookie(id+"-pos-y",newtop,30);
curElement=null; // non sono sicuro che questo sia corretto
}
function SetCookie(cookieName,cookieValue,nDays) {
var today = new Date();
var expire = new Date();
if (nDays==null || nDays==0) nDays=1;
expire.setTime(today.getTime() + 3600000*24*nDays);
document.cookie = cookieName +"="+ escape(cookieValue) +";expires="+ expire.toGMTString();
}
function ReadCookie(cookieName) {
var theCookie=""+document.cookie;
var ind=theCookie.indexOf(cookieName);
if (ind==-1 || cookieName=="") return "";
var ind1=theCookie.indexOf(';',ind);
if (ind1==-1) ind1=theCookie.length;
return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}
hai anche bisogno di una funzione che ti legga i cookie