Click to See Complete Forum and Search --> : Controling popups and parent windows


manual
09-09-2003, 06:56 AM
Greetings ya'all

I have created a website where the visitor can click on a link, whereupon he gets a popup in which he can choose between two PDF documents to be displayed, Currently when he clicks on either link, the popup closes and displays the chosen document in the parent window. Which is actually fine, but I want the popup to close and open the chosen document in a new (fullscreen) window. The parent window from which the popup was opened should also stay open.
Below the script I am currently using ...

<a href="javascript:self.close();" onclick="goAndClose('../mydoc.pdf')">Document1</a>

<script>
<!--
function goAndClose(page)
{
opener.location.href = page
this.close;
}

//-->
</script>

Charles
09-09-2003, 06:59 AM
<a href="../mydoc.pdf" onclick="window.open(this.href, 'child'); return false">Document1</a>

manual
09-09-2003, 08:38 AM
Thanx Charles

One thing though the popup window does not close. When I click on Document1, the new window opens as required, but the popup stays open.

Charles
09-09-2003, 12:53 PM
<a href="../mydoc.pdf" onclick="window.open(this.href, 'child'); if (self.opener && !self.opener.closed) self.opener.close(); return false">Document1</a>

manual
09-10-2003, 02:23 AM
Hi Charles
I realy appreciate the help. JavaScript stays one of my constant headaches, I cannot seem to wrap my mind around it.
Ok, with your script above the following happens. When I click on Document1 I get a message "This programm is trying to close this window" If I say "yes" the parent window closes, the popup stays open, and the document1 opens in a new window.
I want to keep the parent window open, close the popup and open the Document1 in a new full window.

Thanks again for the help, it is appreciated.

Charles
09-10-2003, 05:29 AM
I need you to more fully explain what you are trying to accomplish. At first I thought you had two window and now it looks loke you have three.

manual
09-10-2003, 05:52 AM
Hi Charles
Thanx again for the help ...

Yes there are 3 windows

1-fullscreen
2-popup
3-fullscreen

On window 1 I have a link "Documents", when the user clicks on it it opens window 2 (the popup) here the visitor can choose Document1 or Document2. If he clicks on either of them, the popup should close and open the selected document (pdf format) in a new window 3. Window 1 should stay open throughout all of this.
I would have included direct links to the documents, unfortunately I have a bit of a space problem on the page and the client requested it this way. The client is king, right?
Thanx again ...