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.

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.