Skip to main content

How to create app shortcuts

 


How to create app shortcuts

                                                                                    HTML

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="color-scheme" content="dark light" /> <link rel="manifest" href="manifest.json" /> <title>How to create app shortcuts</title> <script> if ('serviceWorker' in navigator) { window.addEventListener('load', () => { navigator.serviceWorker.register('sw.js'); }); } </script> <script type="module" src="script.js"></script> </head> <body> <h1>How to create app shortcuts</h1> <ol> <li> You can drag these <a href="blue.html">blue page</a> or <a href="red.html">red page</a> links to the bookmarks bar and access them later. </li> <li> Install the app by clicking the button below. After the installation, the button is disabled. <p> <button disabled type="button">Install</button> </p> </li> </ol> </body> </html>

How to create app shortcuts 

                                        
                                        JASON

{ "name": "How to create app shortcuts", "short_name": "App shortcuts", "start_url": "../demo.html", "icons": [ { "src": "../icons/favicon.png", "type": "image/png", "sizes": "512x512" } ], "shortcuts": [ { "name": "Feel blue", "short_name": "Blue", "description": "Open a blue webpage", "url": "../blue.html", "icons": [{ "src": "../icons/blue.png", "sizes": "192x192" }] }, { "name": "Feel red", "short_name": "Red", "description": "Open a red webpage", "url": "../red.html", "icons": [{ "src": "../icons/red.png", "sizes": "192x192" }] } ], "display": "standalone" }


How to create app shortcuts


                                        JS

// The install button. const installButton = document.querySelector('button'); // Only relevant for browsers that support installation. if ('BeforeInstallPromptEvent' in window) { // Variable to stash the `BeforeInstallPromptEvent`. let installEvent = null; // Function that will be run when the app is installed. const onInstall = () => { // Disable the install button. installButton.disabled = true; // No longer needed. installEvent = null; }; window.addEventListener('beforeinstallprompt', (event) => { // Do not show the install prompt quite yet. event.preventDefault(); // Stash the `BeforeInstallPromptEvent` for later. installEvent = event; // Enable the install button. installButton.disabled = false; }); installButton.addEventListener('click', async () => { // If there is no stashed `BeforeInstallPromptEvent`, return. if (!installEvent) { return; } // Use the stashed `BeforeInstallPromptEvent` to prompt the user. installEvent.prompt(); const result = await installEvent.userChoice; // If the user installs the app, run `onInstall()`. if (result.outcome === 'accepted') { onInstall(); } }); // The user can decide to ignore the install button // and just use the browser prompt directly. In this case // likewise run `onInstall()`. window.addEventListener('appinstalled', () => { onInstall(); }); }

Comments

Popular posts from this blog

How to access contacts from the address book

                   HTML    How to access contacts from the address book <! DOCTYPE html > < html lang = " en " > < head > < meta charset = " utf-8 " /> < meta name = " viewport " content = " width=device-width, initial-scale=1 " /> < link rel = " icon " href = " data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🎉</text></svg> " /> < title > How to access contacts from the address book </ title > </ head > < body > < h1 > How to access contacts from the address book </ h1 > < p > Ship your order as a present to a friend. </ p > < button hidden type = " button " > Open address book </ button > < pre > </ pre > < label > Na...

HOW TO CREATE COPY BUTTON WITH HTML, CSS AND JS LANGUAGE

                                                                                                                                                      STRUCTURE WITH  <HTML> <! DOCTYPE html > < html lang = " en " > < head > < meta charset = " utf-8 " /> < meta name = " viewport " content = " width=device-width, initial-scale=1 " /> < link rel = " icon " href = " data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text...

How to create Source Code To Apple Logo Using Python turtle

Source Code To Apple Logo Using Python turtle   import turtle as t t.begin_fill() t.Screen().bgcolor( 'Gray' ) t.fillcolor( 'black' ) t.left( 134 ) for i in range ( 30 ):     t.forward( 1 )     t.left( 1 ) t.right( 5 ) for i in range ( 35 ):     t.forward( 1 )     t.left( 1 ) t.left( 5 ) t.forward( 30 ) for i in range ( 15 ):     t.forward( 0.7 )     t.right( 3 ) t.forward( 25 ) t.left( 5 ) for i in range ( 50 ):     t.forward( 1 )     t.left( 1 ) t.right( 3 ) for i in range ( 50 ):     t.forward( 1 )     t.left( 1 ) t.right( 5 ) for i in range ( 45 ):     t.forward( 2 )     t.left( 1 ) t.right( 5 ) for i in range ( 40 ):     t.forward( 2 )     t.left( 1 ) t.left( 5 ) for i in range ( 20 ):     t.forward( 1 )     t.left( 2 ) t.left( 5 ) t.forward( 15 ) for i in range ( 9 ):     t.forward( 2 ) ...