Published on 2006-02-19 20:49:33
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/'});
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/'});
Member of the PHP Magazine Network, Copyright (C) 2005-2009 phpmagazine.net All Rights Reserved