Loading ...
Sorry, an error occurred while loading the content.

Re: Thumbnail gallery

Expand Messages
  • davidblackledge
    ... things ... Since to do the popup, you ll have to provide the filename to the function, you might as well provide the width and height also. In that case
    Message 1 of 2 , May 31, 2002
    • 0 Attachment
      --- In javascript3@y..., pamrwright <no_reply@y...> wrote:
      > I'm creating an online photo album with several thumbnails on one
      > page. I would to be able to click on a thumbnail and open up a new
      > window containing the larger version of a picture. Here is my
      > problem: Each of the photos is a different size, and I would like
      > find a way to have the new windows fit the size of each photo, while
      > still utilizing the same script for each photo. Or, if this is
      > impossible and I have to have a uniform size for all the pop up
      > windows, I would at least like to set a background color for the
      > windows other than the default tan color. Are either of these
      things
      > possible using Javascript? I'm very new at this. Thanks!

      Since to do the popup, you'll have to provide the filename to the
      function, you might as well provide the width and height also. In
      that case you'll be in good shape:

      function popUpPicture(url,w,h) {
      var w = window.open(url,"_blank","width="+(w+10)+"height="+(h+10));
      w.document.bgColor = "green";
      w.focus();
      }

      ... onclick="popUpPicture('images/myPic.jpg',238,516);return false;"

      That adds 10 pixels to the size of the window just in case the
      particular browser doesn't set the INSIDE size and instead is setting
      the OUTSIDE size. Using _blank for the name makes sure each popup is
      in a new window because IE won't re-size an already-open window
      (thought Netscape 4 will). The .focus() on the end is just in case
      the window ends up behind other windows (not really an issue when each
      popup uses a new window, but if you were sharing window names, it
      would be an issue). I don't know that the background color setting
      will really work... it might fire before the image loads, then the
      image loading resets the background color. I dunno. There are other
      ways to do it by writing an HTML document into the new window that
      includes an IMG tag and a BODY tag with a background color, but this
      is simpler if it works for you.

      Haven't tried it, but it should get you most of the way there.

      David.
      http://David.Blackledge.com
    Your message has been successfully submitted and would be delivered to recipients shortly.