PDA

View Full Version : Callback function when popup is closed



hieu79vn
20 Sep 2012, 9:02 AM
Hi

I'm sorry for asking this javascript question here
But if you know how we set a call back function for window.open('url',....), please help me

To be clear I would like to do like this

var win = window.open(url,...);
win.onclose = function(){alert('popup is closed')};

Thank you.

Another question: Is Ext support a window like window.open(url,...) ????

Lunti
20 Sep 2012, 10:13 AM
Why do you need to open a new browser window?

Can't you use Ext.Window?

Is the opened window created by you?

scottmartin
20 Sep 2012, 10:48 AM
Have you tried the onunload event? This may not work in all browsers.

More info:
http://stackoverflow.com/questions/7476660/why-does-window-open-onunload-function-not-work-as-i-expect

Scott.

hieu79vn
21 Sep 2012, 12:19 AM
Thanks Scott

Is there any way to set time out for a local function such as pollForWindowClosure, like this

setTimeout(function(){this.pollForWindowClosure(myWindow)}, 10);

Thank you

hieu79vn
23 Sep 2012, 10:46 PM
Hi,

I tried to catch the onclose event of popup by Ext.TaskManager but i doesnt run. Could you tell me what is the problem in my code?
Thank you

createEditor: function(){
this.editor = Ext.create('widget.texteditor',{
height: 200
});
var toolbar = this.editor.getToolbar();
toolbar.add({
iconCls: 'icon-attachment',
scope: this,
handler: function() {
var myWindow = window.open('<%=PopupUrl(.....................');
this.pollForWindowClosure(myWindow);
}
});
return this.editor;
},
pollForWindowClosure: function(myWindow){
if (myWindow.closed){
this.myFunc();
return;
}
//setTimeout(function(){this.pollForWindowClosure(myWindow)}, 10);
Ext.TaskManager.start({
//run: this.refresh,
run: function(){this.pollForWindowClosure(myWindow)},
scope: this,
interval: 10
});
},
myFunc: function(){
alert('789');
},