...

View Full Version : image zoomer



gordon1986
06-21-2004, 10:57 PM
I am trying to make a script that is used for displaying screenshots.

For every image, there are two versions, a small and large one. The small ones are displayed in a table and when u move the cursor over one of the images, the larger image is displayed over that one in a DIV.

So the cursor moves over a smaller image, a div appears and the center of that DIV (with an image inside it) is centered on the center of the smaller image.

i already have some beginnings, but how do I get the location of an image in the browser?

Garadon
06-21-2004, 11:54 PM
something like this would get the small image top and left position.
<script>
function getRealPos(ele,dir)
{
(dir=="x") ? pos = ele.offsetLeft : pos = ele.offsetTop;
tempEle = ele.offsetParent;

while(tempEle != null)
{
pos += (dir=="x") ? tempEle.offsetLeft : tempEle.offsetTop;
tempEle = tempEle.offsetParent;
}
return pos;
}
function showLIMG(aIMG)
{
var left=getRealPos(aIMG,'x');
var top=getRealPos(aIMG,'y');
}
</script>

....
<img src="smallimage" onmouseover="showLIMG(this)">



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum