Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- Javascript Discussions


tedster - 6:53 am on Jun 25, 2001 (gmt 0)


CLOSING A POP-UP WINDOW

ponytale asked:
>> i need javascript to selfclose a popup window after login (the login opens a new window) <<

My apology to ponytale -- this question was ignored for an entire month. A very belated welcome to the Forum, and I hope this information helps, now or in the future.

The javascript method for closing a window is window.close().

If you use it to close a window that your javascript code opened (the popup in this case) it works without presenting a confirmation alert window. If you use it to close a window that your js didn't open, the user will automatically get the request to confirm the close.

To close the pop-up window when the user's login is submitted, you could call it by including the onSubmit() event handler in the login FORM tag:

<form name="loginform" onSubmit()=window.close()>form content goes here</form>

However, that code might be problematic if the submitted login doesn't validate. You could account for that possibility by having a failed login generate its own, new popup window for the failure message.


Thread source:: http://www.webmasterworld.com/javascript/646.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com