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

onunload与onbeforeunload 页面跳转前 事件 #49

Open
5Mi opened this issue Jul 20, 2016 · 0 comments
Open

onunload与onbeforeunload 页面跳转前 事件 #49

5Mi opened this issue Jul 20, 2016 · 0 comments

Comments

@5Mi
Copy link
Owner

5Mi commented Jul 20, 2016

onunload,onbeforeunload都是在刷新或关闭时调用,可以在<script>脚本中通过 window.onunload来调用。区别在于onbeforeunload在onunload之前执行,它还可 以阻止onunload的执行。

onbeforeunload 是正要去服务器读 取新的页面时调用,此时还没开始读取;而onunload则已经从服务器上读到了需要加载的新的页面,在即将替换掉当前页面时调用。

项目中跳页面使用到了

window.onbeforeunload = function(){
    showLoading();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant