GotFusion.com Where your journey begins
Antons Video ProductionsNetObjects Fusion 7 Websites Portal

 


 

Closing a Pop Up Window with JavaScript

You cannot close the visitors primary browser window or a window you opened with HTML (target="_blank") without getting the Windows Security Alert.  This is a function that is built into Internet Explorer and cannot be overridden. This alert will appear with all IE browsers if you try to close a window that was NOT opened with a JavaScript function. Netscape 6.01 allows all windows to be closed regardless of how they were opened (go figure).

In order to control how a popup window is closed you need to open an HTML page to contain the pop up window's contents (the open script must call an *.html file). If you open just an image in a pop up window (*.jpg or *.gif) you cannot close the pop up from within the window.  The user must click on the pop up window's close button otherwise the window will just submarine and stay open on the taskbar. In order for a pop up window to be closed, a JavaScript close function of some sort must be inserted into the open popup window's HTML. In other words, to be able to control the function of a popup window you must open an HTML document (another web page), only then will you have access to the HEAD and BODY of the document in which to place your close scripts.   Here is the same photo placed within an HTML document with 3 close scripts; an auto close script, a click within window to close script, and a click on text link script (these three close scripts are explained in the various pop up examples used above).

The JavaScript function to close a window is window.close. You can place it within the <BODY> statement with an onClick event, but this will not work with Netscape 4.x browsers.  If you are showing an image with your popup you can make a Smart Link Blank and use the html button to associate the onClick function with the image and this will work with Netscape browsers.

onClick="window.close()"

You can place the same script on the Inside the Tag tab on an image or make a line of text which says click here to close this window.  This will work with all version 4 and above browsers. To do this:

If all of this window mumbo jumbo seems too complicated or confusing for you, here are some URLs for 3rd party NOF components that will open and one that will close pop up windows.  Even using one of these components you will still have to make a new page within your NOF site, with these with the exception of ThumbsUp which creates its own html page. All others will require a manually created page in which to place the contents you want to display and to place your popup window close script in.

Apollon's popup window Component:
http://www.apollon.de/Components/Script/bp.html

CoolMaps' PopRocket popup component:
http://club.coolmaps.com/component_detail.cfm?nfx=25

CoolMaps' ThumbsUp component:
http://club.coolmaps.com/component_detail.cfm?nfx=90

Ingo's close window component will write and place a close window script from either a text link or a graphic close window button (he even gives you the button!). The URL is:
http://www.apollon.de/Components/cbp.html
 


|  Fusion  |  Web Design  |  Hosting  |  Resources  |  gotFusion Store  | 

Problems with this page?  

All content copyright © 2002, 2004 gotFusion LLC.  The name gotFusion and the gotFusion ® logo are registered trademarks of gotFusion LLC
Copyright, legal notice & privacy statement