Content in the Javascript library assumes a sound understanding of ECMAScript, CSS, XHTML and DOM.

Popup window

Code listing for w.js

  1. /*
  2. * file: w.js
  3. * date: 2002-09-28
  4. * info:
  5. */
  6. // popup
  7. function wPop(u, n, w, h, l, t, f) {
  8. var p =, n, 'width='+w+',height='+h+',resizable,'+f);
  9. if (!p.opener) p.opener = window;
  10. // setup
  11. p.resizeTo(w, h);
  12. if (l && t && screen) {
  13. if (l < 0) l += screen.availWidth - w;
  14. if (t < 0) t += screen.availHeight - h;
  15. p.moveTo(l, t);
  16. }
  17. p.focus();
  18. return p;
  19. }
  20. // media window
  21. function mPop(u, n, w, h, l, t) {
  22. return wPop(u, n, w + 12, h + 31, l, t);
  23. }

function wPop(u, n, w, h, l, t, f)

Opens a popup window. If window already exists, will focus (bring to front) and resize as necessary.

String: url to open in window.
String: name of window (used in link targets).
Int: window witdh.
Int: window height.
Int: window position from left (negative, from right).
Int: window position from top (negative, from bottom).
String: window features (scrollbars, statusbar, titlebar, etc). Resizable is always set for accessibility reasons.

function mPop(u, n, w, h, l, t)

Opens a media window. Same as wPop(), but adjusts width (w) and height (h) to account for window borders, title bar etc. This is ideal for media windows to redude cropping of content inside the viewable area. Media windows cannot set features as this will impact on the viewable area.

[ inspire logo ]
Code in the javascript library is free to use. Enjoy! Feedback welcome.
© Ben Boyle 2003.