Have JS Office Add-in close or exit events for the document?

只愿长相守 提交于 2019-12-12 03:26:25

问题


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
});


来源:https://stackoverflow.com/questions/36558311/have-js-office-add-in-close-or-exit-events-for-the-document

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!