Mostly based on Peter Kahrels ScriptUI Guide
var w = new Window ("dialog");
var b = w.add('button',undefined,'Click me');
var small = false;
//~ w.onShow = function () {
//~ w.size = {width: 300, height: 400};
//~ }
b.onClick = function(){
small = !small;
if(small == false){
w.size = {width: 300, height: 400};
}else{
w.size = {width: 100, height: 100};
}
}
w.show();