Yes, you can do this with the meta tag apple-mobile-web-app-capable
and with HTML5 Application Cache. As you discovered, you can add an app to the Home Screen. With this technique, the app will also run offline and full screen.
Add this to your HTML <head>
:
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
Set up your cache:
Add manifest="cache.manifest"
to <html>
. cache.manifest
is the name of the file you'll use to define what to cache. It can be named anything, but I actually call mine cache.manifest
.
<html lang="en" manifest="cache.manifest">
Then make sure your web server has the MIME type for .manifest
set to:
text/cache-manifest
Then create a file named cache.manifest
, put it in your app root. Under the CACHE
section, put the files you want cached (in your case, all files). You can also use *
to mean 'all files'.
Every time you push a release, change the version number in your cache manifest. Any change in the file will work, but the version number is a perfect mechanism for this.
CACHE MANIFEST
#ver 1.0.0
CACHE:
app.html
app.css
app.js
Then put this at the top of your script inside your onload
or equivalent.
function updateVersion( event ) {
window.applicationCache.removeEventListener( 'updateready', updateVersion, false );
if ( window.applicationCache.status == window.applicationCache.UPDATEREADY ) {
//perhaps notify user here
window.applicationCache.swapCache();
window.location.reload();
};
};
if ( window.applicationCache ) {
window.applicationCache.addEventListener( 'updateready', updateVersion, false );
};