This method is not part of a specification.
--- title: BeforeInstallPromptEvent.prompt() slug: Web/API/BeforeInstallPromptEvent/prompt tags: - BeforeInstallPromptEvent - BeforeInstallPromptEvent.prompt() translation_of: Web/API/BeforeInstallPromptEvent/prompt ---
{{APIRef("")}}
{{SeeCompatTable}}
{{domxref("BeforeInstallPromptEvent")}} 接口的 prompt()
方法允许一个开发人员在自己选择的一个时间显示安装提示。
BeforeInstallPromptEvent.prompt()
无
一个空的 {{jsxref("Promise")}}.
let isTooSoon = true; window.addEventListener("beforeinstallprompt", function(e) { if (isTooSoon) { e.preventDefault(); // Prevents prompt display // Prompt later instead: setTimeout(function() { isTooSoon = false; e.prompt(); // Throws if called more than once or default not prevented }, 10000); } // The event was re-dispatched in response to our request // ... });
This method is not part of a specification.
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | {{CompatChrome(45.0)}} [1] |
Feature | Android | Android Webview | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|
Basic support | {{CompatNo}} | {{CompatChrome(45.0)}} [1] | {{CompatChrome(45.0)}} [1] |
[1] Behind the flag: chrome://flags/#bypass-app-banner-engagement-checks