Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[js] 第276天 如何在用户刷新、跳转、关闭浏览器时向服务端发送统计的数据? #1786

Open
haizhilin2013 opened this issue Jan 16, 2020 · 2 comments
Labels
js JavaScript

Comments

@haizhilin2013
Copy link
Collaborator

第276天 如何在用户刷新、跳转、关闭浏览器时向服务端发送统计的数据?

我也要出题

@haizhilin2013 haizhilin2013 added the js JavaScript label Jan 16, 2020
@liwudi
Copy link

liwudi commented Jan 17, 2020

刷新:window.onload事件。
跳转:click事件。
关闭:window.onunload事件。

在这些事件的时机,调用接口,发送数据。
关于数据,一般来说,这些数据会保存在本地的localStorage中,发送完成之后,也必须进行clear或者remove操作。

@xiaoqiangz
Copy link

当浏览器窗口关闭或者刷新时,会触发 beforeunload 事件。当前页面不会直接关闭,可以点击确定按钮关闭或刷新,也可以取消关闭或刷新。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
js JavaScript
Projects
None yet
Development

No branches or pull requests

3 participants