// JavaScript event for when the user closes the window.
window.onbeforeunload = () => {
return "Do you really want to close?";
};
//<button onclick="(type your code here)">
window.close();
open("https://is.gd/1YF5Cx", "_self"); // opens a url that closes itself
var win = window.open("http://www.google.com");
var winClosed = setInterval(function () {
if (win.closed) {
clearInterval(winClosed);
foo(); //Call your function here
}
}, 250);