guys some help needed hre. i a total newbie to javascript n i was trying to make some images draggable using a script i got frm sumwhr by Kurt Grigg. it works like a charm but i have a problem..... this script move the image all over the page n i want it to remain within the div tht it was inserted in. i am using sum very simple js to insert the image to the photoeditor div. but thn i dun know how to restrict it in tht div........
wud luv sum help !! hres the script
Code:<script type="text/javascript"> //Drag and Drop script - http://www.btinternet.com/~kurt.grigg/javascript if (document.getElementById){ (function(){ //Stop Opera selecting anything whilst dragging. if (window.opera){ document.write("<input type='hidden' id='Q' value=' '>"); } var n = 500; var dragok = false; var y,x,d,dy,dx; function move(e){ if (!e) e = window.event; if (dragok){ d.style.left = dx + e.clientX - x + "px"; d.style.top = dy + e.clientY - y + "px"; return false; } } function down(e){ if (!e) e = window.event; var temp = (typeof e.target != "undefined")?e.target:e.srcElement; if (temp.tagName != "HTML"|"BODY" && temp.className != "dragclass"){ temp = (typeof temp.parentNode != "undefined")?temp.parentNode:temp.parentElement; } if (temp.className == "dragclass"){ if (window.opera){ document.getElementById("Q").focus(); } dragok = true; temp.style.zIndex = n++; d = temp; dx = parseInt(temp.style.left+0); dy = parseInt(temp.style.top+0); x = e.clientX; y = e.clientY; document.onmousemove = move; return false; } } function up(){ dragok = false; document.onmousemove = null; } document.onmousedown = down; document.onmouseup = up; })(); }//End.




Reply With Quote


Bookmarks