javascript - Losing reference to child window -


i writing ext js 5 application , seem losing reference child window opening.

the following opens new window w3schools, sample. later, when close window, beforeunload event not fire.

 this.chatpopoutwindow = window                 .open(                     'http://www.w3schools.com',                     'chatpopoutwindow',                     'width=380,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no');             ext.get(me.chatpopoutwindow).on('beforeunload', function() {               .....more code 

in code sample bad url (the new window opens 404 error), when close window beforeunload event fire:

this.chatpopoutwindow = window                 .open(                     '/somebadurl',                     'chatpopoutwindow',                     'width=380,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no');             ext.get(me.chatpopoutwindow).on('beforeunload', function() {               .....more code 

why beforeunload event not triggered in first scenario?

i should have specified window want open not cross-domain; in same domain (though not in example above).

anyway, found answer. apparently, ext js 5's ext.get(me.chatpopoutwindow).on('beforeunload', function() {... not reliable. instead, use me.chatpopoutwindow.onbeforeunload = function() {..., javascript syntax listening beforeunload event..


Comments