Results 1 to 3 of 3

Thread: How to create multiple remote windows on same page

  1. #1
    Join Date
    Mar 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Red face How to create multiple remote windows on same page

    Hey guys...Newbie question here.
    I can't figure this one out. Could you give a quick pointer on javascript?

    I've coded in several links on the same page that will open a remote window. The problem is, if you don't close the previous pop-up window, the next clicked-on link will load in the same remote window. The image inside usually isn't the same size, so it doesn't look right.

    For an example see: http://www.highvalleyranchutah.com/alamar2.html
    First click on a home illustration at the top, then without closing that pop-up, click on a floor plan below. The floor plan outline drawing will load in the previous window instead of a new one. The floor plan is vertical and the home rendering is horizontal. They can't both load in the same window. If clicked independently, they work fine.

    I know it's something simple regarding the naming of the window opener or something. I just don't know what to do. Please help?

    Below is the Javascript code used for the popup:

    function makeRemote(url,winx,winy){
    remote = window.open("","remotewin","SCROLLBARS=0,WIDTH="+winx+",HEIGHT="+winy+",RESIZABLE=0");
    remote.location.href=url;
    if(remote.opener==null) remote.opener = window;
    remote.opener.name="opener";
    }


    Below is an example of how it's called for in the html:

    <div style="padding: 0px; float: left; clear: left; text-align:center;white-space:nowrap;margin-right:20px;">
    <a href="javascript:makeRemote('alamar2_front.html',800,475);">
    <img src="images/alamar2_fnt_sm.jpg" width="255px" height="155"><br><i>Front Elevation.</i></a>
    </div>

    How can I tweak this so it opens a NEW window every time a makeRemote function is called for?

    Thanks for helping this JavaScript newbie.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    In this part of your code:

    Code:
    remote = window.open("","remotewin","SCROLLBARS=0,WIDTH="+winx+",HEIGHT="+winy+",RESIZABLE=0");
    The string "remotewin" is the target/name for the window. If the window doesn't exist, it names it. If it does exist, it targets it. One way to avoid the situation you describe is to use a unique name for each window. To get a unique name you can do this:

    Code:
    <a href="javascript:makeRemote('alamar2_front.html','win1',800,475);"> . . . </a>
    <a href="javascript:makeRemote('another.html','win2',400,275);"> . . . </a>
    Code:
    function makeRemote(url,winame,winx,winy){
    remote = window.open("",winame,"SCROLLBARS=0,WIDTH="+winx+",HEIGHT="+winy+",RESIZABLE=0");
    remote.location.href=url;
    if(remote.opener==null) remote.opener = window;
    remote.opener.name="opener";
    }
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Mar 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Thanks!

    John.... Thanks so much!!!

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
  •