WebApp from Fiddle
HTML
<h1>Sample WebApp</h1>
<section id="uninstalled">
<button id='install'>INSTALL</button>
<p>This app will show a few buttons to see that the app is actually working</p>
</section>
<section id="installed">
<button id="vibrate">Vibrate</button>
<button id="confirm">Confirm</button>
</section>
JavaScript
if (install.state == 'uninstalled') {
// hide the installed section
document.querySelector('#installed').style.display = 'none';
var installButton = document.querySelector("#install");
installButton.onclick = function () {
install("http://jsfiddle.net/zalun/NJk2u/manifest.webapp");
};
} else if (install.state == 'installed') {
// hide the uninstalled section
document.querySelector('#uninstalled').style.display = 'none';
var vibrateButton = document.querySelector('#vibrate'),
confirmButton = document.querySelector('#confirm');
vibrateButton.onclick = function () {
navigator.vibrate(200);
};
confirmButton.onclick = function () {
confirm('Please confirm');
};
}