Snippets v2

Languages
My Snippets

Popup Window that is centered on screen Login or Register to Bookmark this snippet

Description PHP

Create a popup window that is centered on the screen. Just supply the url, window name, width and height of the window.

The Code Download
  1. function jcPopup(url,window_name,wwidth,wheight) {
  2.     //popup window that is centered on the screen.
  3.     if (!url || !window_name) {
  4.         alert ('Invalid parameters for jcPopup()');
  5.             return false;
  6.     }
  7.     if (!wwidth) {
  8.         var wwdith = 500;
  9.     }
  10.     if (!wheight) {
  11.         var wheight = 500;
  12.     }
  13.     if ((screen.availWidth-100) < wwidth) {
  14.         wwidth = (screen.availWidth-100);
  15.     }
  16.     if ((screen.availHeight-100) < wheight) {
  17.         wheight = (screen.availHeight-100);
  18.     }
  19.     window.open(url,window_name,'toolbar=no,width=' + wwidth + ',height=' + wheight + ',left=' + (screen.availWidth/2-(wwidth/2)) + ',top=' + (screen.availHeight/2-(wheight/2)) + ',scrollbars=yes');
  20.     return null;
  21. }
Credits Contact JC

Added by JC on 11th November, 2007

Comments

There are no comments about this snippet.

Post Comment HTML is allowed

You must be registered and logged in to post a comment.

Login here to post a comment