我需要能够检测用户是否刷新了窗口或导航离开(例如到google.com),然后返回页面,以便我可以触发事件。
我尝试了不同的onbeforeunload,但没有检测到它。
我尝试了这个,但它没有起作用或触发console.log。
componentDidUpdate()
{
window.addEventListener("onbeforeunload",function (){
console.log('Page Refreshed')
})
}
然而,这甚至没有触发console.log消息。我也尝试了beforeunload,结果相同。
有什么想法吗?
onbeforeunload
--->beforeunload
- Yousaf