I use the following code to open a new window with window.open and if somebody manually closes the window it will call the pause() function.
<script type="text/javascript">
var win = window.open("link.html", "thePopUp", "");
var pollTimer = window.setInterval(function() {
if (win.closed !== false) { // !== is required for compatibility with Opera
window.clearInterval(pollTimer);
pause();
}
}, 200);
</script>
BUT for that pause() function to work the user will need to be allowing popups for the window to first open and then to manually close it.
I would like the pause() function to be called if the window was never open in the first place so even if they aren’t allowing popups.
Instead of a pop up window I would recommend using a javascript modal pop up instead.
Here is a demo:
Outside HTML (Ajax)would be the best example for you. Have a look at the source code to see how to call this if this is what you want.There are many options for this. Here are a couple jquery options:
I hope this helps. Let me know if you need more of a hand.