Popup JavaScript simplifies generating pop up windows
popup(url, properties)
Usage example:popup('/myPageToPopOpen', {'height': 300, 'width': 500});
When multiple popups will use the same properties you can set defaults via syntax:
popup.height = 300;
popup.width = 500;
popup('/url1');
popup('/url2', {'left': 200, 'top': 250});
All default properties can be overridden by inline definitions:
popup.focus = 1; popup('/url3'); //this will pop in the foreground and take focus
popup('/url4', {'blur': true}); //this will pop in the background
The following optional properties are available:
blur
- (Boolean) sets the popup to open behind the current windowfocus
- (Boolean) sets the popup to take focus once it openscenter
- (Boolean) centers the popup on the screencenterx
- (Boolean) centers the popup horizontally on the screencentery
- (Boolean) centers the popup vertically on the screenid
- this is the internal name for the popup, if you open two popups with the same ID the second one will load in the window of the first. This is used as the second argument towindow.open()
replace
- (Boolean) if true then the new location will replace the current page in the browser's navigation history. Note: many browsers do this anyway. if supplied, this is used as the fourth argument towindow.open()
returnobject
- (Boolean) if Boolean true then thewindow.open
object is returned instead of executed. This grants you total control over the window, allowing you to do things like:
var pop = popup('/somePage', {'returnobject': true});
setTimeout('closepop(pop)', 2000);
If
returnobject
is not defined or is set to false then the return value of popup()
will be Boolean false, this is for convenience as it allows you to easily make pop-ups that degrade gracefully and become ordinary links if JavaScript is turned off: <a href="/myPage" onclick='return popup(this.href)'">
The following properties are also valid and are the arguments built into JavaScript for the window.open function: height, width, outerheight, outerwidth, innerheight, innderwidth, left, top, screenx, screeny, alwayslowered, alwaysraised, channelmode, copyhistory, dependent, directories, fullscreen, hotkeys, location, menubar, resizable, scrollbars, status, toolbar, z-lock
closepop(popupObject)
Closes a popup window. popupObject must be a window object, usually the return of popup() with returnobject set to true or the return of JavaScriptwindow.open()