I need to perform some action before a popup window(using window.open
) closes.
Something like will be good:
var new_window = window.open('some url')
new_window.onBeforeUnload = function(){ my code}
How can I achieve that?
Your example will work as long as the pop-up window url is in the same domain as the parent page, and you change the event to all lowercase:
var new_window = window.open('some url')
new_window.onbeforeunload = function(){ /* my code */ }