Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / January 2005



Tip: Looking for answers? Try searching our database.

Closing a window by not being the url that opened it

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Daniele Baroncelli - 31 Jan 2005 14:28 GMT
Initial situation:

main window of the browser display url A

THEN

- user click on a link (which also opens a popup on the onClick event) to
url B

AS A CONSEQUENCE

- main window displays url B
- a popup is open

THE QUESTION IS:
================

How can close the popup window from the code of url B?
Is there a way to reference the popup window (so that you can call the close
method), although url B didn't open it?

Cheers

Daniele
Dietmar Meier - 31 Jan 2005 15:13 GMT
> How can close the popup window from the code of url B?
> Is there a way to reference the popup window (so that you can call
> the close method), although url B didn't open it?

When you open the popup window in document A, give it a somewhat
"unique" name (second argument of Window.open()).

In document B, you can use Window.open() with an empty string as
the first argument and that "unique" name as second argument to
get popup window referenced.

Example:

Document A
<a href="b.html" onclick="window.open('popup.html','qqwxyyp')">

Document B
function closePopup() {
 var w = window.open('', 'qqwxyyp');
 if (w && !w.closed) w.close();
}

ciao, dhgm
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.