Skip to content

Instantly share code, notes, and snippets.

@chrisjhoughton
Created March 15, 2014 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisjhoughton/9563994 to your computer and use it in GitHub Desktop.
Save chrisjhoughton/9563994 to your computer and use it in GitHub Desktop.
Detect when a popup has closed on the page using polling. Kudos to http://stackoverflow.com/questions/3291712/is-it-possible-to-open-a-popup-with-javascript-and-then-detect-when-the-user-clo for the idea. Polling isn't neat, but there's not a neater way here.
var whenPopupClosed = function (popupWindow, cb) {
var pollTimer = window.setInterval(function() {
if (popupWindow.closed !== false) { // !== is required for compatibility with Opera
window.clearInterval(pollTimer);
cb();
}
}, 200);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment