Popup windows are additional browser window opened from a web page. The popups are opened programmatically using JavaScript.
JavaScript Popup windows are used widely for displaying advertisements. It is a proven method of generating good income from a website.
Uses of Popup Windows
In general the following are the ways to utilize popup windows:
Pay per click advertisements
Banner exchanges
Request survey from the visitors
Request signup to a news letter
Display help (for a form, for example)
Note:
You can create full featured, great looking popups without any programming.
Invocation methods
The invocation of the Popup is dependant on the purpose of the Popup window. A help popup window could be opened when the user clicks on a 'help' link.
Advertisements usually pop up when you visit a web page or when you exit a page.
Based on the invocation method, Popups are of the following types:
Open on entering a page
Open on entering a page; but keep inactive ( also known as Pop Under)
Open on exiting a page
Open when the user clicks on a link or a button
Creating a JavaScript Popup window
In order to invoke the popup window at certain instances (like when the page is loading) you need to understand the event handling. For example, if you want to popup a window when the user visits a page, you need to handle the onLoad event of that page. The following section event handling.
The code below handles the onLoad event and displays a message.
<BODY onLoad="javascript: alert('On Load event fired!')">
The event handler is added in the onLoad event of the <BODY> tag of the page.
Similarly, the following code shows the handler for the unload event.
<BODY onUnload="javascript: alert('Unload event fired!')">
Suppose you want to handle the event when the user clicks on a link. The following code shows handling the click on an anchor
<A href="javascript: alert('Clicked on link!')">Click here!</A>