Reputation: 29
I want to show a popup (Google, Twitter etc) and when users close that dialog, I want to show an alert "bye", but that alert does not appear:
<script>
var openDialog = function(uri, name, options, closeCallback) {
var win = window.open(uri, name, options);
var interval = window.setInterval(function() {
try {
if (win == null || win.closed) {
window.clearInterval(interval);
closeCallback(win);
}
}
catch (e) {
}
}, 1000);
return win;
};
var test = function() {
alert("bye");
};
openDialog("//google.com", "popup", "scrollbars=no", "test");
</script>
Upvotes: 0
Views: 102
Reputation: 2008
This line:
openDialog("//google.com", "popup", "scrollbars=no", "test");
Should read:
openDialog("//google.com", "popup", "scrollbars=no", test);
if you wanted you could also do:
openDialog("//google.com", "popup", "scrollbars=no", function(e){
alert("bye");
});
Upvotes: 0
Reputation: 513
Change this code
openDialog("//google.com", "popup", "scrollbars=no", "test");
with that:
openDialog("//google.com", "popup", "scrollbars=no", test);
Demo: http://jsfiddle.net/3on19uak/
Upvotes: 3