/* ********************************************************* ** OPENWIN.JS - Open Window JS Library ** =================================== ** This library contains JS code to open a new window with ** specified properties: width, height, features, etc. ** It's yours for free, but please maintain this header! ** ** To load this library in an HTML doc, put the following ** line in the doc's HEAD (before any other SCRIPT tags): ** ** ** ** Author Ver Date Comments ** ====== === ==== ======== ** Rick Scott 1.0 1/1/00 First release ** ** Copyright 2000, Rick Scott, all rights reserved. ********************************************************* */ /* ********************************************************* ** USAGE ** ===== ** openWin(url, jsName, htmlName, width, height [, ...]) ** url - absolute or relative URL of doc to load in window ** this can be a blank string "" (will load no doc) ** jsName - name of window to use in JS coding (can be "") ** e.g., to refer to a form in the doc loaded into ** the new window, you'd code: jsName.document.formName ** htmlName - name of window to use in HTML coding (can be "") ** e.g., to make a link target the new window, you'd ** code: link ** width - width (pixels) of window's doc display area ** height - height (pixels) of window's doc display area ** [, ...] - openWin() takes 5 *required* arguments. You ** can also specify 1+ additional *optional* arguments: ** DIRECTORIES, LOCATION, MENUBAR, RESIZABLE, SCROLLBARS, ** STATUS, TOOLBAR, CENTER, UPPERLEFT, UPPERRIGHT (see below). ** ** These are all legal openWin() calls: ** openWin("mydoc.html", "jswin", "", 500, 500); ** openWin("", "", "", 500, 500, RESIZABLE); ** openWin("http://www.yahoo.com", "jswin", "htmlwin", ** 1000, 1000, MENUBAR, STATUS, TOOLBAR, CENTER); ** ** And these are all illegal: ** openWin("mydoc.html", 500, 500); // 2 req args missing ** openWin("", "", "", 500); // 1 req arg missing ** openWin(www.yahoo.com, "jswin", "htmlwin", ** 1000, 1000, MENUBAR, STATUS, TOOLBAR, CENTER); ** // URL must begin with http:// and be in ""s ********************************************************* */ // window features constants var DIRECTORIES = "directories"; // show directory buttons var LOCATION = "location"; // show location bar var MENUBAR = "menubar"; // show menu bar var RESIZABLE = "resizable"; // make window resizable var SCROLLBARS = "scrollbars"; // show scrollbars (if needed) var STATUS = "status"; // show status bar var TOOLBAR = "toolbar"; // show toolbar var CENTER = "center"; // center window var UPPERLEFT = "upperleft"; // display window in upper-left corner var UPPERRIGHT = "upperright"; // display window in upper-right corner // open a new window with specified properties function openWin(url, jsName, htmlName, width, height) { var is4up = true; // for CENTER, UPPERLEFT, UPPERRIGHT features var features = ""; // string to hold features argument if (parseInt(navigator.appVersion) < 4) // set is4up to true/false is4up = false; // build features string features += "width=" + width + ","; // width features += "height=" + height + ","; // height for (var i=5; i