Open-Source PHP Framework - Designed for rapid development of performance-oriented scalable applications

Popup JavaScript simplifies generating pop up windows

API >> webroot >> js >> pop.js

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 1popup('/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 window
  • focus - (Boolean) sets the popup to take focus once it opens
  • center - (Boolean) centers the popup on the screen
  • centerx - (Boolean) centers the popup horizontally on the screen
  • centery - (Boolean) centers the popup vertically on the screen
  • id - 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 to window.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 to window.open()
  • returnobject - (Boolean) if Boolean true then the window.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 JavaScript window.open()