View Full Version : How to create multiple remote windows on same page

03-01-2007, 01:18 AM
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");
if(remote.opener==null) remote.opener = window;

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>

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.

03-01-2007, 06:05 AM
In this part of your 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:

<a href="javascript:makeRemote('alamar2_front.html','win1',800,475);"> . . . </a>
<a href="javascript:makeRemote('another.html','win2',400,275);"> . . . </a>

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

03-02-2007, 02:55 AM
John.... Thanks so much!!!