😆PWA - beforeinstallprompt toplusgames.com (ok)
<html>
<head>
<title>Test</title>
<link rel="manifest" href="manifest.json">
</head>
<body>
<p>
If the <code>beforeinstallprompt</code> event fires, there will be a button displayed allowing
you to use <code>prompt()</code> on the deferred event.
</p>
<button hidden>Show Prompt</button>
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('sw.js');
window.addEventListener('beforeinstallprompt', event => {
event.preventDefault();
var button = document.querySelector('button');
button.removeAttribute('hidden');
button.addEventListener('click', () => {
event.prompt();
button.setAttribute('disabled', true);
});
});
}
</script>
</body>
</html>Áp dụng

How do you prompt a user to install a PWA?
PreviousSử dụng ajax tạo popup cho các bài viết wordrpess mattervn.com (ok)NextHow to Use the HTML5 Full-Screen API (Again) (ok)
Last updated