By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,365 Members | 3,095 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,365 IT Pros & Developers. It's quick & easy.

How to link from a "pop-up" window

P: n/a
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.

Oct 24 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Jo******@gmail.com wrote:
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.
--
Rob
Oct 24 '05 #2

P: n/a
RobG said the following on 10/24/2005 12:44 AM:
Jo******@gmail.com wrote:
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.


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.
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
}
else{
window.open(Href)
}
window.close(); // Close the popup
}
</script>


--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Oct 24 '05 #3

P: n/a
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.

Oct 26 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.