dcsimg
www.webdeveloper.com
Results 1 to 5 of 5

Thread: I need help with this script..

  1. #1
    Join Date
    Nov 2002
    Location
    Regina, SK. Canada
    Posts
    33

    I need help with this script..

    I can't get this script to work...well, at least some of it.
    I want to have a link to open an image in a pop-up style window. I want the window to be the exact same size as my photo. (IE. My image is 200x400, so I want the window to have the same viewing dimensions)

    Here is the script. What is wrong? When I click my link, it DOES bring up a new window with my photograph in it, BUT the new window is not the same size as the photo. The new window is way to big.


    <script language="javascript">
    function popUp(filename,imageWidth,imageHeight) {
    newWin =
    window.open(filename,"myPic","width=imageWidth,height=ImageHeight,menubars=no,scrollbars=no,statusba r=no,locationbar=no");
    }
    </script>



    and in the body...


    click me

  2. #2
    Join Date
    Nov 2002
    Posts
    631
    <script language="javascript">
    function popUp(filename,imageWidth,imageHeight) {
    newWin =
    window.open(filename,"myPic"," width=200,height=400,menubars=no,sc
    rollbars=no,statusbar=no,locationbar=no");
    newWin.document.write(image.jpg);
    }
    </script>

    Then in the body put onClick="javascript: popUp();"

    I think that will work.
    Last edited by Zach Elfers; 11-30-2002 at 01:55 PM.

  3. #3
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,279
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="Content-Script-Type" content="text/javascript">
    <title>Window Example</title>
    <script type="text/javascript">
    <!--
    function popUp (filename,imageWidth,imageHeight) {
    geometry = 'height=' + imageHeight + ',width=' + imageWidth;
    var newWin = window.open (filename, myPic, geometry);
    return false;
    };
    // -->
    </script>
    <p><a href="image.png" onclick="return popUp (this.href, 50, 100)">Image.png</a></p>

  4. #4
    Join Date
    Nov 2002
    Location
    Regina, SK. Canada
    Posts
    33
    Ok. here is what I tried. It did not work. All it did, was open a new window with my image in it. The window did not re-size itself to my image.


    <html>
    <head>
    <title>My page</title>


    <script type="text/javascript">
    <!--
    function popUp (filename,imageWidth,imageHeight) {
    geometry = 'height=' + imageHeight + ',width=' + imageWidth;
    var newWin = window.open (filename, myPic, geometry);
    return false;
    };
    // -->
    </script>


    </head>

    <body bgcolor="#FFFFFF" text="#000000">
    <a href="images/file-ryan.jpg" onclick="return popUp (this.href, 95, 95)"><img src="images/file-corvus.jpg" width="95" height="95" border="0"></a>



    Basically, I had an image on a website...like an icon lets say. I want to be able to click on that icon, and open an image in a pop up window, and have the window automatically rezise to the dimensions of my image.

  5. #5
    Join Date
    Nov 2002
    Location
    Regina, SK. Canada
    Posts
    33
    NEVERMIND! I figured it out. Here is the link I used to do it...

    http://www.crays.com/jsc/jsPImg.htm#popimg

    Works wonderful!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles