JS

JavaScript Demos:
Popup Window.

jim.cerny@unh.edu   13-AUG-1998


Look for the popup window to appear on your screen.


Discussion.

This JavaScript creates a new popup window when the page is loaded (or refreshed). The success of popup windows depends on how much screen real estate you assume is available on the desktop -- and on how you configure the window.

The script is very short. It specifies a window function that is invoked by an event (onLoad on the BODY tag in this case) and then defines the properties of the window. In JavaScript terminology the window object is created with the window.open() method. This function is generalized so that the URL to open in the window is passed as a parameter by the event. The window.open syntax consists of three elements:

  • The variable "URL" for the URL to open in the new window.
  • The window name - useful for future use in a TARGET attribute (not used here).
  • The window features, a comma-separated list that defines the window features. Only a few features are used here.
The only other JavaScript used is the onLoad event in the BODY tag.

To adapt this script, you only need to change the URL in the onLoad event and to tailor the window features to suit your needs. For a detailed discussion of some of the possibilities, see Doc JavaScript.