SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Threaded View

  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2001
    Location
    CA
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Autosizing popup to image size?

    Hi -

    I'm putting together an image gallery on my site, and have a javascript that is "supposed" to allow the visitor to click the thumbnail of an image and have it pop up in a new window that is automatically sized to the width and height (plus padding) of the image. It seems to work... kinda. Problem is, the first time a thumbnail is clicked, it doesn't size the window correctly. Clicking it after that it seems to work fine for the most part. Anyhow, I'm hoping someone can help me get this code working properly...

    You can see it in action at:
    http://www.absolutecross.com/graphics/gallery/

    Here's the code:
    Code:
    <SCRIPT LANGUAGE="Javascript">
    <!-- Begin auto-sizing window script
    function image_open(image_loc)
    {
     var var_image = new Image();
     var_image.src = image_loc;
     width = var_image.width + 20;
     height = var_image.height +30;
     str_style= "\" width="+width+",height="+height+"\"";
     window.open(var_image.src,"myImage",str_style);
     
    }
    //-- End auto-sizing window script -->
    </SCRIPT>
    
    <IMG SRC="http://www.absolutecross.com/images/gallery/thumb_ac-ancient.jpg"
     HSPACE="0" VSPACE="0" BORDER="0" WIDTH="60" HEIGHT="60" BORDER="0" ALT="AC Ancient Panel"
     onclick="image_open('http://www.absolutecross.com/images/gallery/ac-ancient.jpg')">
    Also it seems to add an immense amount of extra width to the window in Netscape 6, and I haven't been able to test it in NS4 and other browsers besides IE6 as I just finished building this computer and haven't located where to download older versions yet hehe...

    Thanks!

    *edit: fixed img code so it wouldnt screw up forum layout
    Last edited by AC Design; Jan 10, 2002 at 04:19.


Bookmarks

Posting Permissions

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