系统相关
首页 > 系统相关> > javascript – 如何判断JS Windows8 metro app是否可见

javascript – 如何判断JS Windows8 metro app是否可见

作者:互联网

我正在尝试创建一个应用程序,当它变得可见时执行一些工作,并在它消失时执行其他工作.这通常通过页面可见性api(http://css.dzone.com/articles/using-html5s-pagevisibility)来完成,但Windows 8:http://msdn.microsoft.com/en-us/library/ie/hh673553(v=vs.85).aspx目前不支持此功能.

有回调onactivated和oncheckpoint但这些回调是针对流程生命周期的,并不一定与应用可见性相关.具体来说,应用程序可以在暂停之前进入后台很长一段时间.

任何帮助,将不胜感激.

– 亨利

解决方法:

我想你想要visibilitychange活动.请参阅文档文档here.有关应用程序生命周期事件here的更多信息.

App visibility

When the user switches from your app to another app,
your app is no longer visible but remains in the running state until
Windows can suspend it (for about 10 seconds). If the user switches
away from your app but activates or switches back to it before Windows
can suspend it, the app remains in the running state.

Your app doesn’t
receive an activation event when app visibility changes, because the
app is still running. Windows simply switches to and from the app as
necessary. If your app needs to do something when the user switches
away and back, it can handle the 07003 |
07004 event.

The visibility event is not serialized with
the resume or activation events. Don’t assume that these events come
in a particular order.

标签:javascript,windows-8,microsoft-metro
来源: https://codeday.me/bug/20191007/1864298.html