Stickybomb Posted April 19, 2007 Share Posted April 19, 2007 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. Quote Link to comment Share on other sites More sharing options...
fenway Posted April 20, 2007 Share Posted April 20, 2007 What doesn't work about it? Quote Link to comment Share on other sites More sharing options...
Stickybomb Posted April 20, 2007 Author Share Posted April 20, 2007 the div does not show up when i mouse over the link Quote Link to comment Share on other sites More sharing options...
fenway Posted April 20, 2007 Share Posted April 20, 2007 It's visibility, no visability.... Quote Link to comment Share on other sites More sharing options...
Stickybomb Posted April 20, 2007 Author Share Posted April 20, 2007 ??? it shows the div but it does not get the coords Quote Link to comment Share on other sites More sharing options...
fenway Posted April 20, 2007 Share Posted April 20, 2007 Which browser? FF and IE use two different event models. Quote Link to comment Share on other sites More sharing options...
Stickybomb Posted April 20, 2007 Author Share Posted April 20, 2007 i am trying it in firefox, i took the code from the example on w3schools page and it work on there site in my browser Quote Link to comment Share on other sites More sharing options...
fenway Posted April 23, 2007 Share Posted April 23, 2007 I'm fairly sure you have to pass the event from the handler to the function. 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.