SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Sep 2000
    Location
    Ontario, Canada
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    dynamic popup window size

    I have various php scripts on my site where the user can click on a thumbnail image and a larger image will load in a popup window. The only problem is that sometimes the window is too small for the image.

    here's my current code called from a sitewide .js file:

    Code:
    function openUp(thePage) {
    emailWin=window.open(thePage,'fullsize','width=350,height=455')
    }
    my current popup links are like this: <a href=\"javascriptpenUp('full.php?img=$img')">view full size</a>

    Basically, I was wondering if its possible to assign width/height based on the actual size of the image. I know how to get the dimensions of the image in php but passing them to a javascript link is my problem right now. If possible, I'd like to keep the javascript functions inside of the main .js file.

    Any ideas on how I could get this to work are appreciated Thanks.
    Jason Dulberg
    Extreme MTB
    http://extreme.nas.net

  2. #2
    SitePoint Zealot
    Join Date
    Dec 1999
    Posts
    137
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First rename your main.js file to main.php.
    Then do the following:

    PHP Code:
    <?php $size=getimagesize($img); ?>

    function openUp(thePage){
    emailWin=window.open(thePage,'fullsize','<?php echo $size[3]; ?>');
    }
    Basically, that should do it. To link your main.php file to your html and parse the code as JS just use the tag:

    <script language="Javascript" src="./main.php">

    Anarchos has a very well done script like this in his site.

    Hope that helps

  3. #3
    SitePoint Addict
    Join Date
    Sep 2000
    Location
    Ontario, Canada
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok... cool. Thanks for your code and the link. I got it working perfectly now
    Jason Dulberg
    Extreme MTB
    http://extreme.nas.net


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
  •