We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Learn more about funding links in repositories.
Report abuse
There was an error while loading. Please reload this page.
第276天 如何在用户刷新、跳转、关闭浏览器时向服务端发送统计的数据?
我也要出题
刷新:window.onload事件。 跳转:click事件。 关闭:window.onunload事件。
在这些事件的时机,调用接口,发送数据。 关于数据,一般来说,这些数据会保存在本地的localStorage中,发送完成之后,也必须进行clear或者remove操作。
当浏览器窗口关闭或者刷新时,会触发 beforeunload 事件。当前页面不会直接关闭,可以点击确定按钮关闭或刷新,也可以取消关闭或刷新。
Activity
liwudi commentedon Jan 17, 2020
刷新:window.onload事件。
跳转:click事件。
关闭:window.onunload事件。
在这些事件的时机,调用接口,发送数据。
关于数据,一般来说,这些数据会保存在本地的localStorage中,发送完成之后,也必须进行clear或者remove操作。
xiaoqiangz commentedon Aug 30, 2022
当浏览器窗口关闭或者刷新时,会触发 beforeunload 事件。当前页面不会直接关闭,可以点击确定按钮关闭或刷新,也可以取消关闭或刷新。