How to link from a "pop-up" window

J

JohnEGee

Hello, all, and TIA for any help you can offer. I've searched the
Internet for answers and have finally come here.

I've created a page (several, actually) with a link that opens a pop-up
window. It's a pop-up window in the sense that it's smaller than the
man page and is intended to be viewed and then closed.

The problem is that if I include a link on that pop-up window HTML
page, when the link is clicked the new page opens IN the pop-up window,
which is not at all what I want. I want the pop-up window and the
window it came from to be closed out altogether first so that the new
page, the I link to from the pop-up window, opens in the user's default
browser view and the original pages are "released."

You can see a sample of the originating page with a link on it that
opens a pop-up window, whereupon you'll see a test link to google.
Please go to http://barelybad.com/map_test.htm.

Please understand that I am nearly illiterate in Javascript. I can
follow directions, and I can adapt within reason, but I really will
need some pretty detailed instructions as to what goes where in which
HTML page.

Thanks again for your time.
 
R

RobG

Hello, all, and TIA for any help you can offer. I've searched the
Internet for answers and have finally come here.

I've created a page (several, actually) with a link that opens a pop-up
window. It's a pop-up window in the sense that it's smaller than the
man page and is intended to be viewed and then closed.

The problem is that if I include a link on that pop-up window HTML
page, when the link is clicked the new page opens IN the pop-up window,
which is not at all what I want. I want the pop-up window and the
window it came from to be closed out altogether first so that the new
page, the I link to from the pop-up window, opens in the user's default
browser view and the original pages are "released."

You can see a sample of the originating page with a link on it that
opens a pop-up window, whereupon you'll see a test link to google.
Please go to http://barelybad.com/map_test.htm.

Please understand that I am nearly illiterate in Javascript. I can
follow directions, and I can adapt within reason, but I really will
need some pretty detailed instructions as to what goes where in which
HTML page.

Thanks again for your time.

Using pop-ups like this is not liked much, better to use a normal menu
system. But anyhow...

The following script checks to see that the opener is not closed. If it
isn't it must be open, so its location.href is set to the value passed
to the function. If the opener is closed, the pop-up just closes.

In the HTML source for your popup, add the following in the head:


<script type="text/javascript">

function changeOpenerHref(Href)
{
if (opener && !opener.closed){ // Make sure opener is open
opener.location.href = Href; // Change the href
}
window.close(); // Close the popup
}
</script>


To call the function, the href of the A element is used as a URL to pass
to the function using an onclick. This means that browsers that show
the href as a tooltip or in the status bar can still do so.

Change the link in the document body:


<a href="http://www.google.com"
onclick="changeOpenerHref(this.href);">Google.com</a>

<a href="http://www.apple.com"
onclick="changeOpenerHref(this.href);">Apple.com</a>

<!-- Add more ... -->



You can add lots of links and use the same function call each time.
 
R

Randy Webb

RobG said the following on 10/24/2005 12:44 AM:
Using pop-ups like this is not liked much, better to use a normal menu
system. But anyhow...

The following script checks to see that the opener is not closed. If it
isn't it must be open, so its location.href is set to the value passed
to the function. If the opener is closed, the pop-up just closes.

That seems to be anti-user friendly, with the popup issue aside. Only
close the popup after the new URL has been addressed. If the opener is
closed, then open a new window.
 
N

Nick E. Name

Thank you to RobG and Randy Webb for your help. The solution I
crafted based on your advice isn't ideal, but it's good enough.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top