在safari里有时候不触发,ie10以下不触发 可以使用polify
pagelifecycle.js
document.addEventListener("visibilitychange",function(){
if(document.visibilityState=="visible"){
// console.log("欢迎回来");
location = location
//do something
//继续视频播放
}
if(document.visibilityState=="hidden"){
console.log("不要走!")
//do something else
//暂停视频播放
}
})
参考
https://www.cnblogs.com/wangmaoling/p/8022561.html
https://www.jianshu.com/p/4e5de223b8db
https://blog.csdn.net/weixin_42861240/article/details/94555114
https://blog.csdn.net/gg451516921/article/details/79133029
// window.addEventListener('pageshow', function(event) {
// dispLog("PageShow Event " + event.persisted);
// console.log(event)
// })
# [ios 返回不会自动刷新页面问题]
[https://www.cnblogs.com/jrg-Archer/p/7150579.html](https://www.cnblogs.com/jrg-Archer/p/7150579.html)
$(function () {
var isPageHide = false;
window.addEventListener('pageshow', function () {
if (isPageHide) {
window.location.reload();
}
});
window.addEventListener('pagehide', function () {
isPageHide = true;
});
})