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. Link to comment https://forums.phpfreaks.com/topic/120242-is-there-a-way-to-find-mouse-position-on-the-site/ 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> Link to comment https://forums.phpfreaks.com/topic/120242-is-there-a-way-to-find-mouse-position-on-the-site/#findComment-619489 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.