Skip to content

Instantly share code, notes, and snippets.

@simplelife7
Created January 19, 2016 11:23
Show Gist options
  • Save simplelife7/3218db482fafdc5d1d90 to your computer and use it in GitHub Desktop.
Save simplelife7/3218db482fafdc5d1d90 to your computer and use it in GitHub Desktop.
【JS】判断页面是否从缓存取的onpageshow
window.addEventListener('pageshow', function(e) {
if (e.persisted) {// 从缓存加载
//...
}
}, false);
//jquery中没有这个对象,需要用原生事件对象
$(window).bind("pageshow", function(event) {
if (event.originalEvent.persisted) {
//..
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment