Javascript 在jquery中检测浏览器关闭事件,但不检测页面刷新

Javascript 在jquery中检测浏览器关闭事件,但不检测页面刷新,javascript,Javascript,我尝试过这个链接,但它也会在页面刷新时被触发。 这是手动刷新时的手柄 window.onbeforeunload = function (event) { //action }; 这是手动刷新的句柄 window.onbeforeunload = function (event) { //action }; 手动或实际刷新页面?为什么标记为[typescript]?之所以标记为typescript是因为我在typescript中尝试了此代码。使用“event.curren

我尝试过这个链接,但它也会在页面刷新时被触发。
这是手动刷新时的手柄

window.onbeforeunload = function (event) {
    //action 
};

这是手动刷新的句柄

window.onbeforeunload = function (event) {
    //action 
};

手动或实际刷新页面?为什么标记为[typescript]?之所以标记为typescript是因为我在typescript中尝试了此代码。使用“event.currentTarget.performance.navigation.type”确定手动或实际刷新页面的导航类型?为什么标记为[typescript]?已标记Typescript,因为我已在Typescript中尝试此代码。请使用“event.currentTarget.performance.navigation.type”确定导航类型