I am opening a child window for Facebook sharing this way:
window.open(sharingUrl,'','toolbar=0,status=0,width=626,height=436');
The window is automatically closed when a user clicks share or close…
Is there a way to add a listener to these events?
If you store a reference to the child window when you call
window.open(), then you can poll usingsetInterval()to see whether the window is still open using thewindow.closedproperty. The example below checks twice per second.Note to others: If you are ever in a situation where you have control over the html in the child window, you could make use of the onbeforeunload event and alert the parent window.