Closing a window can be done by calling the window's close() method. However, by default this is possible only for windows that were opened using JavaScript; if you try this on other windows, the user gets a warning message similar to the one shown in Figure 9.4 (Mozilla browsers have a similar message, but hide it in the JavaScript console). Figure 9.4. Close only the windows opened with JavaScriptor cope with this frightening message.
With the sitemap from the previous phrase, a link to close the window comes in handy: The Sitemap with the Close Link (sitemapwindow.html)
However, you should also close the sitemap from the main window if another page is loaded there. In the current example, loading any other page in the main window redirects the browser off to another web server; therefore, you can close the sitemap immediately. But before doing so, you should check whether the window is already closed, by taking a look at its closed property: Opening the Sitemap with the Auto-Closing Feature (sitemapwindow.html)
|