javascript - Can mobile h5 detect refreshing or leaving the page?
过去多啦不再A梦
过去多啦不再A梦 2017-05-16 13:34:58
0
2
556

Can I monitor the page refresh or leave this page on the mobile h5 page?

过去多啦不再A梦
过去多啦不再A梦

reply all(2)
左手右手慢动作

You can use onbeforeunload and onunload

迷茫

You can use HTML5’s Page Visibility API

document.visibilityState: Values ​​representing the following 4 possible states:
hidden: the page is in the background tab or the browser is minimized
visible: the page is in the foreground tab
prerender: the page performs pre-rendering processing off the screen document. The value of hidden is true
unloaded: The page is being unloaded from memory
Visibilitychange event: This event is triggered when the document changes from visible to invisible or from invisible to visible.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!