Created
March 15, 2014 09:29
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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