Stop native web app from reloading itself upon opening on iOS

cguedel picture cguedel · Nov 27, 2010 · Viewed 16.8k times · Source

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?

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

Answer

ghenne picture ghenne · Dec 15, 2010

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.