Created
June 7, 2012 03:56
-
-
Save to/2886473 to your computer and use it in GitHub Desktop.
Fake Pageshow Event for iOS Home App
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var time = Date.now(); | |
setInterval(function(){ | |
var now = Date.now(); | |
if(now - time > 5000) | |
alert('pageshow(fake)'); | |
time = now; | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
iOS 5のSafariにはwebkitvisibilitychange/visibilitychangeが存在せず、ウィンドウのfocus/blurも動作しない。
pageshow/pagehideはあるが、ホームに置いたアプリではロック復帰後にイベントが発生しない。
これを回避するため、タイマのズレからバックグラウンドを判定しpageshowの代わりとした。