Jump to content

[SOLVED] relative to mouse position?


Stickybomb

Recommended Posts

i am trying to write a script that displays a div relative to where yor mouse is located when you mouse over a link

 

this is the code i put together

 

<script type="text/javascript">

	function getX(){
	var xpos;
	xpos=event.clientX;

	return xpos;
	}

	function getY(){
	var ypos;
	ypos=event.clientY;

	return ypos;
	}

	function show(pop_id){
	var img,popup;
	img="fig"+pop_id;
	popup=document.getElementById(img);
	popup.style.visability='visible';
	popup.style.top=getX();
	popup.style.left=getY();
	}

	function hide(pop_id){
	var img,popup;
	img="fig"+pop_id;
	popup=document.getElementById(img);
	popup.style.visability='hidden';
	}

	</script>

 

this is the html i am using to call the script

 

<a href="#" class="pop" onmouseover="show(1);" onmouseout="hide(1);">Figure 1</a>

 

its been a while since i messed with javascript and i can't seem to get this to work i basically took the code directly from the w3schools example i fund while doing a search on the subject. Any help is appriciated.

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.