yanivkalfa Posted August 18, 2008 Share Posted August 18, 2008 for eg if i want to make a sort of thumbnails window . with a div .. and i want this thumbnails window to fallow the mouse position . so i want to have a link .. with onmouseover . to first find mouse location and then find the div i uses to the thumbnails window .. and then change its Left and top acording to mouse position .. thanks alot for any help. Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 18, 2008 Share Posted August 18, 2008 Here is a simple way to drag and drop. You can just modify it to not stop on mouseup. <html> <head> <script language="JScript"> function startDrag(e) { var offsetX = event.clientX-parseInt(e.style.left); var offsetY = event.clientY-parseInt(e.style.top); document.onmousemove = function() { e.style.left = event.clientX-offsetX; e.style.top = event.clientY-offsetY; } document.onmouseup=function() { document.onmousemove=null; } } </script> </head> <bodY> <div STYLE="position:absolute;width:100px;height:100px;background-color:#0000FF;left:0px;top:0px" onmousedown="startDrag(this)"></div> </body> </html> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.