Resize an existing popup window

Discussion in 'Javascript' started by Nigel Molesworth, Jun 24, 2005.

  1. I'm using a combination of various "googled" scripts to generate
    borderless pop-ups when a thumbnail is clicked, see below. At present it
    works OK, a new image takes the place of an old one, the pop up goes if
    you close the parent etc.

    My problem is that I would really like to resize an existing window if
    one exists, rather than close and make a new one. See ******

    I've tried .resizeTo() but it seems to come up with a tiny window.

    Any thoughts?




    var popwin='';

    function viewPic(img)
    {
    picfile = new Image();
    picfile.src =(img);
    fileCheck(img);
    }


    function fileCheck(img)
    {
    if( (picfile.width!=0) && (picfile.height!=0) )
    {
    checkExisting(img);
    }
    else
    {
    funzione="fileCheck('"+img+"')";
    intervallo=setTimeout(funzione,50);
    }
    }


    function checkExisting(img)
    {
    if (popwin.location && !popwin.closed)
    {
    popwin.close();
    makeWindow(img)
    //popwin.location.href = img; need a tidy here, but it works ******
    // popwin.focus();
    }
    else {makeWindow(img)}
    }


    function makeWindow(img)
    {
    ht = picfile.height;
    wd = picfile.width;

    var args= "height=" + ht + ",innerHeight=" + ht;
    args += ",width=" + wd + ",innerWidth=" + wd;

    popwin=window.open("","_blank",args)
    popwin.document.open()
    popwin.document.write('<html><head><title>'+img+'</title></head><body
    bgcolor=white scroll=no topmargin=0 leftmargin=0 rightmargin=0
    bottomargin=0 marginheight=0 marginwidth=0> <div style="position:
    absolute; top:0px;left:0px"><a href="javascript:window.close()"> <img
    src="'+img+'" width="'+wd+'" height="'+ht+'"
    border="0"></a></div></body></html>')
    popwin.document.close()
    }


    function tidy() {
    if (popwin.location && !popwin.closed) {
    popwin.close(); }
    }

    // Based on JavaScript provided by Peter Curtis at www.pcurtis.com &
    // http://www.therotunda.net/code/autosized-popup-window.html -->
    Nigel Molesworth, Jun 24, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Terren

    Resize popup window to fit text

    Terren, Sep 28, 2005, in forum: ASP General
    Replies:
    4
    Views:
    187
    Evertjan.
    Sep 29, 2005
  2. Jens Peter Hansen
    Replies:
    7
    Views:
    503
    Randy Webb
    Jun 19, 2004
  3. Raffi
    Replies:
    4
    Views:
    205
    Dr John Stockton
    Aug 12, 2004
  4. GTi
    Replies:
    1
    Views:
    108
    Thomas 'PointedEars' Lahn
    Feb 5, 2006
  5. James Black

    user can't resize popup window in IE

    James Black, Apr 27, 2006, in forum: Javascript
    Replies:
    5
    Views:
    227
    James Black
    May 2, 2006
Loading...

Share This Page