I'm currently develop a JS Office Add-in, but I could'n find any reference in API Documentation (https://dev.office.com/reference/add-ins/) for an close document or exit document event. I need to suscribe it to show the user warning message about save plugin settings
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
There are no events like that in the current version of the Add-in API.
回答2:
Try this code:
window.addEventListener("beforeunload", function (e) {
var confirmationMessage = "\o/";
(e || window.event).returnValue = confirmationMessage; //Gecko+IE
return confirmationMessage; //Webkit,Safari,Chrome
});