在 iOS 上打开时阻止本机 Web 应用程序重新加载自身 [英] Stop native web app from reloading itself upon opening on iOS

查看:26
本文介绍了在 iOS 上打开时阻止本机 Web 应用程序重新加载自身的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 iOS 上使用 HTML + JS 构建原生 Web 应用程序".如您所知,您可以将这样的应用程序添加到主屏幕,它或多或少看起来就像一个普通的本机应用程序.

I'm trying to build a "native web app" using HTML + JS on iOS. As you may know you can add such an application to the homescreen and it will more or less look just like a normal native app.

但是,如果我退出这样的应用程序并再次重新打开它,它会再次重新加载整个页面.当通过多任务栏从另一个应用程序切换到此类应用程序时,也会发生这种情况.

However if I quit such an app and reopen it again it reloads the whole page again. This also happens when switching to such an application from another over the multitasking bar.

这是预期的行为还是有办法阻止设备这样做?

Is this expected behaviour or is there a way to stop the device from doing this?

例如,您可以将 jqTouch-Demos 从这里添加到您的主屏幕并进行测试:http://jqtouch.com/preview/demos/main/

As an example you can add the jqTouch-Demos from here to your homescreen and test it: http://jqtouch.com/preview/demos/main/

推荐答案

您可以将应用程序的状态保存在 localStorage 中.重新启动时,检查状态是否正在运行,然后将应用程序恢复到上次所在的位置.

You could save the state of your app in localStorage. On restart, check to see if the state is running, then restore the app to where it last was.

这篇关于在 iOS 上打开时阻止本机 Web 应用程序重新加载自身的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆