Opening Multiple Windows

Sometimes you’ll want to open multiple windows using a script; for example, you might want to create a script that opens a different window every time the user clicks an on-screen control. Or possibly you want to open several windows, all at the same time. As usual, JavaScript is up to the task. In this example, we have a page with a link; clicking it opens up several separate windows, each containing an image. Script 6.4 shows you how it’s done, and Figure 6.5 shows the result.

Figure 6.5. Clicking the link opened all four child windows; the placement was determined by the browser. In this case, Safari opened all the windows on top of one another, and we moved them for clarity’s sake.

To open multiple windows: ...

Get JavaScript and Ajax for the Web: Visual QuickStart Guide, Seventh Edition 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.