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
  1. #1
    New Coder
    Join Date
    Jul 2002
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question My javascript picture handler needs tweaking...

    Hello all..

    I got these 2 beautiful scripts from this site about 18 months ago, that allow me to show a photo gallery on screen that creates both small thumbnails and then blows up the photo to a set size. It works great....

    But now, I've a need to a modification. I am now creating an "articles" gallery that will have .jpgs and .pdfs in it. Each should appear in the nice little rows and each when clicked must now open up to whatever size they ARE width wise with a scroll bar for height -- rather than my set sizes as per these two scripts...

    ======================================================
    <script language=Javascript type="text/Javascript">

    function popImg(imageURL) {
    var imgWin = window.open('about :blank','imgWin','width=200, height=200, left=100, top=100');

    with (imgWin.document) {
    writeln('<html><head><title>Articles Gallery</title>');
    writeln('<style type="text/css"><!-- body { margin: 0px; } --></style></head>');
    writeln('<body onload="self.focus();"><img id="pic" style="display:none" width="400" height="300" /></body></html>');
    // set the width/height above to control how the pic is sized
    close();
    }
    var img = new Image();
    img.onload = function() { sizeImgWin(imgWin, img) };
    img.src = imageURL;
    }

    function sizeImgWin(win, img) {
    var new_w = 400;
    var new_h = 300;
    // set the above numbers to be same as the writeIn line above to control
    // how big the picture is blown up to...cool!
    var old_w = win.innerWidth || win.document.body.offsetWidth;
    var old_h = win.innerHeight || win.document.body.offsetHeight;
    if (!new_w) { new_w = old_w; }
    if (!new_h) { new_h = old_h; }
    new_w -= old_w; new_h -= old_h;
    win.resizeBy(new_w,new_h);
    win.document.title = img.src.substring(img.src.lastIndexOf("/")+1);
    var pic = win.document.getElementById('pic');
    pic.src = img.src;
    pic.style.display = 'block';
    }
    </script>
    ================================================

    Could someone show me how to do that? I realize that the vars new_w and new_h must be redone to instead "measure" the size of each article (they will be cut out of trade journals and newspapers etc.) for the display, but I can't figure out how to do this myownself....

    ???

    Jim

  • #2
    New Coder
    Join Date
    Jul 2002
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Well....

    then does anyone know how to do this without using these functions, ie any other function?

    Jim


  •  

    Posting Permissions

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