Click to See Complete Forum and Search --> : Close a window by name?


briandunning
12-03-2003, 07:03 PM
How can I close a window by its name? If I know there is another window open with a window.name=("thing"), what's the syntax to close it? I know that thing.close won't work.

For extra credit: how do I prevent IE from displaying a JavaScript error if I try to close that window when it doesn't exist (if the user has already closed it manually, for instance)?

Thanks!

fredmv
12-03-2003, 07:13 PM
Originally posted by briandunning
How can I close a window by its name? If I know there is another window open with a window.name=("thing"), what's the syntax to close it? I know that thing.close won't work.I don't believe you can. If, for example, foo is a reference to the new window, you could use:foo.close();Originally posted by briandunning
For extra credit: how do I prevent IE from displaying a JavaScript error if I try to close that window when it doesn't exist (if the user has already closed it manually, for instance)?if(typeof foo != 'undefined') foo.close();