View Full Version : image zoomer

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?

06-21-2004, 11:54 PM
something like this would get the small image top and left position.
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');

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