I opened the popup window in Javascript and want to get the event when it is closing.
// Main.js
const fnPopup = () => {
var popup = window.open('', 'pChk', 'width=500, height=500, scrollbars=no, status=no, menubar=no');
popup.onbeforeunload = () => {
console.log("[NOTIFY] This Popup will be closed");
};
};
Above code is working well. When popup is closed, TEST console log is printed. BUT I should submit the data by form because some some authorization data should be sent. So I changed the code like below but it is not working well.
// Main.js
const fnPopup = () => {
var popup = window.open('', 'pChk', 'width=500, height=500, scrollbars=no, status=no, menubar=no');
popup.onbeforeunload = () => {
console.log("[TEST] This Popup will be closed");
};
document.autho_form.action = "https://myAuthorizationSite.com/autho.cb"; // The site of Service Provider (Not our code)
document.autho_form.target = "pChk";
document.autho_form.submit();
};
In this case, above TEST console log is printed once while move to action site. But after page is moved, TEST log didn't printed although popup window is closed.
SUMMARY: Can anybody help to teach the way to get the event when the popup window which is submitted by form is closed? Additionally, I should modify Main.js only. Thanks in advance.