« DiggLicious, an AJAX Blended version of Digg and del.icio.us | Main | My-BIC, LIGHT and TASTY New AJAX/PHP framework »

Prototype-powered Popups

Jonathan Snook have written Prototype-powered Popups object to answer Peter Cooper's Prototype-inspired popup object. His script requires Prototype's Object.extend() feature to map parameters over default values, you can find it in two flavors :

var Popup = {
  open: function(options)
  {
    this.options = {
      url: '#',
      width: 300,
      height: 300
    }
    Object.extend(this.options, options || {});
    window.open(this.options.url, '', 'width='+this.options.width+',height='+this.options.height);
  }
}

Popup.open({url:'http://www.example.com/'});

And :

var Popup = Class.create();
Popup.prototype = 
{
  initialize: function(options)
  {
    this.options = {
      url: '#',
      width: 300,
      height: 300
    }
    Object.extend(this.options, options || {});
    window.open(this.options.url, '', 'width='+this.options.width+',height='+this.options.height);
  }
}
new Popup({url:'http://www.yahoo.com/'});
Bookmark this article at these sites
Post a comment





(Email will remain hidden)





Please enter the security code you see here




Related entries
Email to a friend
Email this article to:


Your email address:


Message (optional):