I am making an Excel add-in by Excel JavaScript API. There is a button in this add-in, clicking on it launches
window.open("https://localhost:3000/#/new/", "popup", "width=1000, height=1100") and popups a browser window.
The new page is built by angularjs. It can send postMessage to the add-in opener by $window.opener.postMessage(msg, $window.opener.location.href). Now, I want to add a real-time flag to the page to specify if the page is connected to its opener add-in.
For example, when the new page popups, the flag shows connected. If we close the Excel file (eg, close the Excel program in Windows, close the browser tab in Excel online), normally the popup browser window does not close systematically, but we want the flag to show disconnected.
Does anyone know if there is any close events of add-in/file/program by Excel JavaScript API. If so, we could send a message by postMessage from the add-in to the popup browser window when the event is triggered.
Otherwise, on the side of the popup browser window, what would be an efficient way to detect if its opener is still alive?
Is it the case that you want the popup to stay open (and say disconnected) sometimes? Or would you prefer to have it close automatically when the host add-in closes? If you want the latter, then use the Dialog API.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With