当我的应用程序被终止时,我想执行一些操作。可以使用哪种方法进行此操作?我正在做React Js。
发布于 2019-07-17 17:05:41
防止整个浏览器被杀死是不可能的,因为这种行为很容易被恶意脚本利用。但是,您可以检测选项卡何时关闭。
window.addEventListener('beforeunload', function (e) {
// Cancel the event
e.preventDefault();
// Chrome requires returnValue to be set
e.returnValue = '';
});https://stackoverflow.com/questions/57072136
复制相似问题