SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist pip's Avatar
    Join Date
    Jun 2001
    Location
    Cape Town, South Africa
    Posts
    548
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Calling on a window that was opened by the parent, from the parent

    Hi,

    My script launches a small window to preview thumbnails in, and sets its size and screen position based on variables passed through the function and image dimension sizes.

    How would I call on a window that was opened by the parent window. ie. if I have a thumbnail window, I would like to call on it if it's open, otherwise merely launch a new window.
    - Pip
    ---------------------------------------------------------------------------------
    Nothing takes the taste out of peanut butter quite like unrequited love.

  2. #2
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If the window's open already then JavaScript will automatically use it again providing it has the same name every time. The only thing you need to do is add a window_name.focus(); to the end of your function to bring the window to the front once it's opened or if it's already open ...

    G

  3. #3
    SitePoint Evangelist pip's Avatar
    Join Date
    Jun 2001
    Location
    Cape Town, South Africa
    Posts
    548
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Shot for your reply G.

    I already know that, and already have included it in my script, but my reason for wanting to re-call on the window, is because I don't just need to focus the window again, I need to send through new paramaters to the window, which controls the sizing and and positioning on the screen.

    What makes this difficult to do dynamically is, the window that opens doesn't load any existing document. Instead, the code for the document is included in the script, and gets written when the function is called. In other words, there exists no page or document anywhere on my site for the body of the popup window.

    So now, once again... I need to somehow reference back to the window.

    Isn't there some method to call a window's children by specifying the child window's name?
    - Pip
    ---------------------------------------------------------------------------------
    Nothing takes the taste out of peanut butter quite like unrequited love.

  4. #4
    SitePoint Evangelist pip's Avatar
    Join Date
    Jun 2001
    Location
    Cape Town, South Africa
    Posts
    548
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nevermind... I feel like a dork for the stupid question.

    I've added an onLoad event to the dynamically generated code to automatically resize and position the window:

    Code:
    	var iScreenHeight = screen.height;
    	var iScreenWidth = screen.width;
    	var win = window.open("","ThumbnailView","width=" + parseInt(parseInt(imgWidth)+2) + ",height=" + parseInt(parseInt(imgHeight)+30) + ",scrollbars=no,menubar=no,status=no,resizable=no");
    	var sHTML = "";
    	sHTML += '<HTML>\n\n<HEAD>\n<TITLE>\nView Thumbnail - MHG\n</TITLE>\n\n';
    	sHTML += '<LINK REL="STYLESHEET" TYPE="text/css" HREF="/library/include/css/default.css">\n';
    	sHTML += '<STYLE TYPE="text/css">BODY { background-image: none; }</STYLE>\n\n';
    	sHTML += '<BODY onLoad="self.resizeTo(' + parseInt(parseInt(imgWidth)+12) + ',' + parseInt(parseInt(imgHeight)+59) + ')"';
    	sHTML += ' TOPMARGIN="0" LEFTMARGIN="0" TOPMARGIN="0" LEFTMARGIN="0">\n\n';
    	sHTML += '<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%">\n';
    	sHTML += '<TR><TD CLASS="MHGToolbar">\n';
    	sHTML += '<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%">\n';
    	sHTML += '<TR><TD STYLE="border-bottom: solid #000000 1px; font-family: Arial, Helvetica, Geneva; font-size: 12pt; font-weight: BOLD; color: #FFFFFF;">\n';
    	sHTML += '&nbsp;&nbsp;' + thumbName + '\n';
    	sHTML += '</TD><TD WIDTH="67">\n';
    	sHTML += '<A HREF="JavaScript:self.close()"><IMG SRC="/library/images/btn_close-2.gif" WIDTH="67" HEIGHT="28" ALT="Close Thumbnail view" BORDER="0"></A>\n';
    	sHTML += '</TD></TR>\n';
    	sHTML += '</TABLE>\n';
    	sHTML += '</TD></TR>\n';
    	sHTML += '<TR><TD STYLE="border: solid #000000 1px;">\n';
    	sHTML += '<IMG SRC="/library/images/' + thumbURL + '" WIDTH="' + imgWidth + '" HEIGHT="' + imgHeight + '">\n';
    	sHTML += '</TD></TR>\n';
    	sHTML += '</TABLE>\n\n';	
    	sHTML += '</BODY>\n</HTML>\n';
    	var d = win.document;
    	d.open();
    	d.write(sHTML);
    	d.close();
    	win.moveTo((iScreenWidth-imgWidth)/2,((iScreenHeight-imgHeight)/2)-20);
    	win.focus();
    	return;
    - Pip
    ---------------------------------------------------------------------------------
    Nothing takes the taste out of peanut butter quite like unrequited love.

  5. #5
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry -- I was a little slow there. You don't need me anyway!

    G


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
  •