Jump to content

is there a way to find Mouse position on the site ?


yanivkalfa

Recommended Posts

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.

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.