Developer

Open multiple windows

There are times when you'll want to open a second window to display related links or other information. This JavaScript windows tip shows you how.

By Brent Lee Metcalfe

Often, you want to open a second window to display related links or other information to the user. Use the code in this tip to open more than one window simultaneously. This creates a parent/child relationship between the new JavaScript-generated windows and the window that launched them.

Four windows open, each positioned in a corner of your desktop. The new windows close when you click the main browser window.

To create this effect, I defined four windows, each in its own function. Next, I created a function (winBig()) that invokes the four functions that define the respective windows:

function winBig() {
  win1(150,150);
  win2(175,175);
  win3(200,200);
  win4(225,225);
}

You can't define multiple windows in a single function call; it won't work.

Multiwindow UIs can benefit users by conserving desktop real estate and distinguishing between navigation and destination, among other things.

Brent Lee Metcalfe is a Web architecture consultant.

Editor's Picks