JavaScript Help

Discussion in 'OT Technology' started by PBizme, May 7, 2003.

  1. PBizme

    PBizme I Got Nothing

    Joined:
    Jan 27, 2002
    Messages:
    729
    Likes Received:
    0
    Location:
    Purdue
    I'm trying to write a function that allows me to pop up a window with a picture when the user clicks on a thumbnail. The problem is the big pictures are different sizes. How can I get the window to change sizes depending on the picture size? Right now it takes the height and width from the first picture and makes the window that size, but then it doesn't change the window size when I click on the second one. Here is what I have:

    artwin=null
    function winopen(file,width,height) {
    if (!artwin || artwin.closed) {
    artwin = window.open (file,'artwin',"resizable=yes,width="+width+",height="+height);

    } else {
    artwin.location=file;
    artwin.focus();
    }
    }

    I have tried putting artwin.height=height; and artwin.width=width; in the else part but that doesn't seem to do it. Anyone able to help me out?
     
  2. SkyRealms

    SkyRealms New Member

    Joined:
    May 26, 2003
    Messages:
    329
    Likes Received:
    0
    Location:
    Cinci
    (First HTML File)

    (In the head...)

    <script language="Javascript">
    function PopupPic(sPicURL) {
    window.open( "imagepopup.html?"+sPicURL, "",
    "resizable=1,HEIGHT=200,WIDTH=200");
    }
    </script>

    (At the pic link...)

    <a href="javascript:popupPic(' You Image ')">

    (Make a second standard file that does not have to change, copy this exactly)

    <HTML>
    <HEAD>
    <title>Whatever</title>
    <script language='javascript'>
    var arrTemp=self.location.href.split("?");
    var picUrl = (arrTemp.length>0)?arrTemp[1]:"";
    var NS = (navigator.appName=="Netscape")?true:false;

    function FitPic() {
    iWidth = (NS)?window.innerWidth:document.body.clientWidth;
    iHeight = (NS)?window.innerHeight:document.body.clientHeight;
    iWidth = document.images[0].width - iWidth;
    iHeight = document.images[0].height - iHeight;
    window.resizeBy(iWidth, iHeight);
    self.focus();
    };
    </script>
    </HEAD>
    <BODY onload='FitPic();' topmargin="0"
    marginheight="0" leftmargin="0" marginwidth="0">
    <script language='javascript'>
    document.write( "<img src='" + picUrl + "' border=0>" );
    </script>
    </BODY>
    </HTML>

    (If you want to see an example, goto http://jmook.net and click on the comic of the day.)
     
    Last edited: Jul 26, 2003

Share This Page