homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

popup window to close on next page loaded

10+ Year Member

Msg#: 772 posted 10:38 am on Mar 25, 2003 (gmt 0)

hi all,

i am wanting to popup a window on submission of my page 1. when page to arrives, after all the processing id like the popup to close itself.

i have no idea how to do this ... :-s
any help much appreicated





WebmasterWorld Senior Member drdoc us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 772 posted 3:16 pm on Mar 25, 2003 (gmt 0)

if(window_name.close()) {
// Nothing here...

Just replace window_name with the actual name of the window. You can use that as an onload() function or just directly in the script while the page is loading... The if thingy is to avoid JavaScript errors if the window was already closed.


WebmasterWorld Senior Member 10+ Year Member

Msg#: 772 posted 5:33 pm on Mar 25, 2003 (gmt 0)

Maybe I'm wrong but I think this is actually a bit more tricky than it seems....

The 'window name' is the name that you can use in the target attribute of a link (<a href="..." target="window_name">) and this isn't normally a globally scoped object or variable name.... therefore the following script:


Would result in an error as myWindowName is not declared as a javascript object.... Normally you would create the window open as an instance of a script object so that you can access the properties and methods (like close()) e.g:

var objWindowInstance = window.open('myPage.htm','myWindowName');

Now, this will work but the problem is you need to close it on the onload of a subsequent page after this page has unloaded.

This is a particular problem as the objects that belong to the initial page are 'undeclared' when the page unloads and therefore are no longer available for any subsequent pages. I've tried using window.frames['myWindowName']close() but without success.

The only real way I can see of handling this is to use a frameset (with a hidden frame) that will hold the objWindowInstance variable or to close the window onload of the initial page.

Any ideas anyone? Maybe I'm being nuts and not seeing the plain obvious.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved