Esta funcion permite abrir una ventana con javascript (popup) enviandole ciertas opciones

JavaScript:
  1. /**
  2. *
  3. *  Javascript open window
  4. *  http://www.webtoolkit.info/
  5. *
  6. **/
  7.  
  8. function openWindow(anchor, options) {
  9.  
  10.     var args = '';
  11.  
  12.     if (typeof(options) == 'undefined') { var options = new Object(); }
  13.     if (typeof(options.name) == 'undefined') { options.name = 'win' + Math.round(Math.random()*100000); }
  14.  
  15.     if (typeof(options.height) != 'undefined' && typeof(options.fullscreen) == 'undefined') {
  16.         args += "height=" + options.height + ",";
  17.     }
  18.  
  19.     if (typeof(options.width) != 'undefined' && typeof(options.fullscreen) == 'undefined') {
  20.         args += "width=" + options.width + ",";
  21.     }
  22.  
  23.     if (typeof(options.fullscreen) != 'undefined') {
  24.         args += "width=" + screen.availWidth + ",";
  25.         args += "height=" + screen.availHeight + ",";
  26.     }
  27.  
  28.     if (typeof(options.center) == 'undefined') {
  29.         options.x = 0;
  30.         options.y = 0;
  31.         args += "screenx=" + options.x + ",";
  32.         args += "screeny=" + options.y + ",";
  33.         args += "left=" + options.x + ",";
  34.         args += "top=" + options.y + ",";
  35.     }
  36.  
  37.     if (typeof(options.center) != 'undefined' && typeof(options.fullscreen) == 'undefined') {
  38.         options.y=Math.floor((screen.availHeight-(options.height || screen.height))/2)-(screen.height-screen.availHeight);
  39.         options.x=Math.floor((screen.availWidth-(options.width || screen.width))/2)-(screen.width-screen.availWidth);
  40.         args += "screenx=" + options.x + ",";
  41.         args += "screeny=" + options.y + ",";
  42.         args += "left=" + options.x + ",";
  43.         args += "top=" + options.y + ",";
  44.     }
  45.  
  46.     if (typeof(options.scrollbars) != 'undefined') { args += "scrollbars=1,"; }
  47.     if (typeof(options.menubar) != 'undefined') { args += "menubar=1,"; }
  48.     if (typeof(options.locationbar) != 'undefined') { args += "location=1,"; }
  49.     if (typeof(options.resizable) != 'undefined') { args += "resizable=1,"; }
  50.  
  51.     var win = window.open(anchor, options.name, args);
  52.     return false;
  53.  
  54. }

Popularidad: 14%