Window Open Function
from builder.com

Here's a reusable window-opening function that puts all the options at your fingertips. The openAnyWindow() function, shown below, lets you pass everything as parameters--the URL, the name, and all the window features, including width and height.

function openAnyWindow(url, name) {
  var l = openAnyWindow.arguments.length;
  var w = "";
  var h = "";
  var features = "";

  for (i=2; i<l; i++) {
    var param = openAnyWindow.arguments[i];
    if ( (parseInt(param) == 0) ||
      (isNaN(parseInt(param))) ) {
      features += param + ',';
    } else {
      (w == "") ? w = "width=" + param + "," :
        h = "height=" + param;
    }
  }

  features += w + h;
  var code = "popupWin = window.open(url, name";
  if (l > 2) code += ", '" + features;
  code += "')";
  eval(code);
}

 

Here's A Commented Version:
function openAnyWindow(url, name) {

  // store number of arguments passed in
  var l = openAnyWindow.arguments.length;

  // initialize w (width)
  var w = "";
  // initialize h (height)
  var h = "";
  // initialize features (comma-delineated list of window features)
  var features = "";

  // loop through array of arguments to build list of features
  // begin loop with 2 (third element of array) to skip url and name
  for (i=2; i<l; i++) {

    // store current argument in variable param
    var param = openAnyWindow.arguments[i];

    // if param isn't a number, it's not width or height
    // in that case, append to features with comma
    if ( (parseInt(param) == 0) || (isNaN(parseInt(param))) ) {
      features += param + ',';

    // else param is a number; must be width or height
    } else {

      // if w hasn't been set yet, param must be the width
      // otherwise, w has been set, so param must be the height
      (w == "") ? w = "width=" + param + "," : h = "height=" + param;
    }
  }

  // append width and height strings to list of features
  features += w + h;

  // begin building statement to open window
  var code = "popupWin = window.open(url, name";

  // if l>2, there were more than two arguments
  // in that case, append comma, parenthesis, and list of features
  if (l > 2) code += ", '" + features;

  // finish building statement to open window
  code += "')";

  // execute statement to open window
  eval(code);
}
<!-- Copyright 1995-98 CNET, Inc. All rights reserved. -->

The openAnyWindow() function is remarkably easy to use. You call it with a list of parameters in the following order:

1. URL
2. Name
3. Any of the other window features (make sure to put them in quotes) and width and height (in number of pixels, with or without quotes), in any order

For example, a call might look like this:

<a href="javascript:openAnyWindow('foo.html',
  'remote', 400, 500, 'scrollbars', 'status');">
  open remote</a>

or like this:

<a href="javascript:openAnyWindow('foo2.html',
  'moreRemote', 'toolbar', 'resizable', 480, 200);">
  open moreRemote<a>

You can make as many calls to the function as you want from a given page, with a different list of parameters each time. Note that if you don't include width and height, the pop-up window will default to the size of the window it's opened from.