Forum Moderators: open

Message Too Old, No Replies

javascript onmouseover

javascript onmouseover show / hide image

         

bingara

1:04 pm on Apr 5, 2008 (gmt 0)

10+ Year Member



Hello,

I've created a text family tree, I want to show person's picture when mouse is over the person's name, it works with a few lines, but if I have to scrolled down the page, I lost my picture, how can I show the picture always at the same location of cursor?

Here is my html page:

<head>
<script type="text/javascript">
<!--
function showPerson(imgsrc, e){
var x = e.clientX;
var y = e.clientY;
var im = document.getElementById("persPic");
im.style.left = (x+2) + "px";
im.style.top = (y+2) + "px";
im.src = imgsrc;
im.style.display="block";
}
function hidePerson(){
var im = document.getElementById("persPic");
im.style.display="none";
}
-->
</script>
</head>
<body>
<img id="persPic" src="" alt="Person's image" style="position:absolute; top:0px; left:0px; display:none;" />
<a href="#" onmouseover="showPerson(Person's image, event);" onmouseout="hidePerson();">Person's name</a>
</body>

Thank you for your help.

httpwebwitch

3:12 pm on Apr 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you might enjoy putting the photo in a Tip [demos.mootools.net]

httpwebwitch

3:13 pm on Apr 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



oh - and welcome to WebmasterWorld, bingara!

bingara

5:50 pm on Apr 6, 2008 (gmt 0)

10+ Year Member



thank you for your advise, I'll try ...