有没有办法让移动 Safari WebApp“忘记”它的状态?
我有一个 新生桥牌评分 应用程序,该应用程序存储在本地iPod touch/iPhone(iPad?可能会很糟糕......)
到目前为止一切顺利,有一个自定义图标滚动和基本的 JS 导航布局,但我的问题是当我退出应用程序时它保留其状态。有一个简单的神奇苹果元标签吗?还是用javascript实现的?
感谢您的任何见解。
I have a nascent bridge scoring app that is meant to be stored locally on an iPod touch/iPhone (iPad? Would probably be fugly...)
So far so good, got a custom icon rolling and basic JS navigation laid out, but my problem is that it retains its state when I quit the app. Is there a simple magic Apple meta tag for this? Or is it achieved with javascript?
Thanks for any insight.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当你说
您的意思是您目前只是通过移动 safari 进行测试?如果是这样,那么该状态自然会被记住。关闭 iPhone 上的 Safari 相当于最小化桌面上的浏览器。如果有空闲内存,该进程将在后台运行。
如果您通过phonegap 或类似方式将其打包成独立进程,那么您将不会再看到这种行为,因为退出时内存会自动刷新。
如果您想将其保留为基于网络的应用程序,那么让它保持其状态(除非刷新)将是预期的行为。
据我所知,将应用程序添加到主屏幕也会刷新内存。
我知道在本机 safari 中刷新状态的唯一方法是通过 window.location.reload() 。问题是无法知道何时调用它。您可以监听窗口焦点,但如果您在选项卡之间切换,则会触发窗口焦点 - 这可能会非常令人沮丧。
When you say
Do you mean you are currently just testing via mobile safari? If so then naturally the state will be remembered. Closing safari on the iphone is comparable to minimizing your browser on a desktop. Provided there is memory free the process is held in the background.
Were you to package it up into a standalone process via phonegap or alike then you wouldn't see this behavior anymore as the memory is flushed automatically upon quit.
If you want to leave it as a web based app then having it hold it's state unless refreshed would be the expected behavior.
Adding the app to your home-screen also flushes the memory as far as I remember.
The only way I know to refresh the sate in the native safari would be via
window.location.reload()
. The problem with this is there is no way to know when to call this. You could listen for window focus but that would fire if you switched between tabs for example - which could be very frustrating.