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/'});


Subscribe to AJAX Magazine's feed