Click to See Complete Forum and Search --> : Popup window within a popup window...


Misterq
02-20-2004, 07:44 AM
Hi

I am trying to create a popup window withing another popup window.

The code so far is

<html>
<head><title></title>
<script type="text/javascript">
<!--
closetime=0;

function Start(URL){
windowprops="directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no,width=250,heig ht=300,left=25,screenX=25,top=25,screenY=25";
preview=window.open(URL,"popWin",windowprops);
if (closetime) setTimeout("preview.close();", closetime*1000);
}

function popupWin(){
url="defaultmusicplayer.html"
delay=0;
timer = setTimeout("Start(url)", delay*1000);
window.status="Mr Q Music";
}
//-->
</script>
</head>

<body>
<a href="javascript:popupWin();">
<div align="center"><font face="Trebuchet MS" class="fsx05" color="#ffffff"><B>MUSIC:</B></font><br>

</span>
</div>
</a>
</body>
<br>
<div align="center">
<font face="Trebuchet MS" class="fsx03" color="#ffffff">A selection of Mr Q's tracks, including <i>Flame in the Dark</i> and <i>Fate</i>.<br></font></div>
</div>
</html>

When I click on the resulting link, the new page opens in the existing page (ie the first popup, not shown here). I'm guessing it's to do with the same name "function popupWin()" used in both cases but, as I'm quite a novice, I don't know what to change to create the desired effect.

Many thanks in advance

Mr Q

Pittimann
02-20-2004, 07:57 AM
Hi!

Probably you have the first popup also opened like this:

preview=window.open(URL,"popWin",windowprops);

If so, use a different var for the second window, example:

preview2=window.open(URL,"popWin",windowprops);

Cheers - Pit

Misterq
02-20-2004, 08:02 AM
Thanks for the quick reply!

Where exactly should I insert the alteration (what you suggested) into the script (shown in previous post).

Sorry for my ignorance...

Mr Q

jaegernaut
02-20-2004, 08:09 AM
You can change this and it should work as well:

Was:
preview=window.open(URL,"popWin",windowprops);

Now:
preview=window.open(URL,"",windowprops);

When you name a popup, and then try to open another with the same name it populates in the same window. Remove that name and it should work for you.

Misterq
02-20-2004, 08:14 AM
Thanks guys, seems to be working now...

:D

Misterq
02-20-2004, 09:59 AM
OK, another problem...

There are more than one links in the first popup window that I want to 'popup'. Unfortunately, it seems that they can only access one link when using the methods suggested above. Is there a way of making the individual links point to different pop-ups?

Thanks

Mr Q

mrchipps69
02-20-2004, 10:19 AM
if you have a popup window that opens the page that makes popups and need more popups from there then you may think of using the _blank window name...

if you use preview=window.open(URL,"_blank",windowprops);

it should open it in a new window every time, regardless...

and I am almost completely certain that you can use _blank with the window.open method... should help you out...

Misterq
02-20-2004, 10:41 AM
This works, thanks, but unfortunately the problem still remains: that is, that all the popups from the one site are identical, even though their links are different.

Anyone know of any solution?

Thanks

Mr Q

Pittimann
02-20-2004, 11:03 AM
Hi!

It is because the variable URL never changes. To avoid problems with unnecessary linebreaks when posting the code here, I put it in the attachment.

You will have to pass the url as an argument whenever calling the function; I added a second link to show you an example...

Cheers - Pit

Misterq
02-20-2004, 11:11 AM
Thankyou very much, Pittimann

I'll download the file and see if it does the trick...

Cheers

Mr Q

Pittimann
02-20-2004, 11:32 AM
Hi!

You're welcome!

To make it work you will have to replace second.html in the line:
<a href="#" onClick="popupWin('second.html');return false;">
with the name (and path before, if necessary) of the file to be opened when the second link is clicked. For further links, use the same syntax with the according filenames.

Like usually, I forget to add "return false;", please add it for every link (see the red code)...

Cheers - Pit