SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Adjusting Pop-up Size to Match Image

    I'm working on a series of articles in which I'd like to use JavaScript pop-up windows. I copied a code from one of this forums' stickies that's supposed to work even when JavaScript is disabled.

    Below is the script I'm tentatively using to open images in pop-ups:

    Code:
    <a href="images/Firefox/FirefoxToolbars.png" target="new" onclick="window.open( this.href, this.target, 'resizable=1,' ); return false;">Click here!</a>
    The width of the image appears to determine the width of the pop-up (in Firefox, anyway). But the images are sometimes far taller than necessary. Is there a way to make the pop-up matches an image's size? For example, if an image is 200 pixels wide and 400 pixels high, the pop-up would also be 200 px wide and 400 px high.

    But I don't want to insert "200 px X 400 px" in the code; I'm just wondering if there's some way to make the pop-up automatically mimic the image's size. My pages use PHP, so maybe that could be part of the solution.

    I have a couple related questions. First, can anyone refer me to a reference that lists all the options that can be included in a pop-up script (e.g. width, height, resizable, scrollbars, etc.)? Below is a script I'm tentatively going to use for opening pages with text as pop-ups. It seems to be adequate, but I'd like to know what other extras are available.

    Code:
    <a href="Browser_Wars.php" target="new" onclick="window.open( this.href, this.target, 'width=500, height=400, resizable, scrollbars' ); return false;">Click here!</a>
    Finally, just out of curiosity, how can these scripts work even when JavaScript is disabled? That's pretty cool. It's nice not having to link to any scripts in my head section or add an "onLink" attribute to my body tag.

    Thanks.

  2. #2
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I googled the subject of this thread and found the following.


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
  •