Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: image zoomer

  1. #1
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    image zoomer

    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?

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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)">


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •