Skip to content

Instantly share code, notes, and snippets.

@csuwildcat
Created March 2, 2023 17:10
Show Gist options
  • Save csuwildcat/44061085cbd35ab0edb3ecbd0a79da5e to your computer and use it in GitHub Desktop.
Save csuwildcat/44061085cbd35ab0edb3ecbd0a79da5e to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title></title>
<script type="module">
window.addEventListener('beforeinstallprompt', (event) => {
// Prevent the mini-infobar from appearing on mobile.
event.preventDefault();
console.log('👍', 'beforeinstallprompt', event);
// Stash the event so it can be triggered later.
window.deferredPrompt = event;
// Remove the 'hidden' class from the install button container.
divInstall.classList.toggle('hidden', false);
});
window.addEventListener('click', e => {
console.log(window.deferredPrompt, e);
})
</script>
</head>
<body style="background: transparent;">
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment