|
Post by Schubaltz on Jul 5, 2007 13:45:08 GMT -5
Description: A function that'll allow you to drag and drop anything on the page. Play around with it, might be useful.
var r = false; document.onmousedown = function(e) { if(!e) var e = event; e = (e.target || e.srcElement); if(e.nodeType == 3) e = e.parentNode; r = e; return false; } document.onmouseup = function() { r = false; } document.onmousemove = function(e) { if(!e) var e = event; if(r) { var x = 0, y = 0; if(e.pageX) { x = e.pageX; y = e.pageY; } else { x = (e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft); y = (e.clientY + document.body.scrollTop + document.documentElement.scrollTop); } if(r.style.position != "absolute") r.style.position = "absolute"; r.style.left = x - 10; r.style.top = y - 5; } }
|
|
|
Post by Jeeeeeel on Feb 23, 2008 18:31:38 GMT -5
"might be usefull" It is usefull my friend. I'm glad I've joined this forum now. This code is gonna help me a lot of mess around with JavaScript/ Perl and (My)SQL.
|
|