Skip to content
Amal Hashim
All posts
Snippet

JavaScript Popup Close Event Handling

Run code when a popup window opened with window.open is closed, using the onbeforeunload event.

1 min read#JavaScript#jQuery

To run code when a popup window is closed, attach a handler to its onbeforeunload event.

js
var popupWindow = window.open(url);

popupWindow.onbeforeunload = function() {
   //Do processing

   return null;
}