Making Popups

A popup window is really just a page like any other. You put the content of the popup into an HTML file, just as you would for a normal Web page, and you can link to the popup window anywhere on your site. However, instead of specifying the path to the page as you would for a normal link:

<a href="popup.htm">Open the popup window</a>

you direct the browser to a simple JavaScript function instead:

<a href="javascript:doPopup('popup.htm');">Open the popup window</a>

This function instructs the browser to open the page in its own window instead of loading the page in the main window. You can write your own JavaScript to do the job, or you can use this one:

 <script language="JavaScript"> function doPopup(popupPath) { window.open(popupPath,'name', ...

Get Web Design Garage now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.