この記事はまだボランティアによって 日本語 に翻訳されていません。ぜひ MDN に参加して翻訳を手伝ってください!
この記事を English (US) で読むこともできます。

The Window.onbeforeinstallprompt property is an event handler for processing a beforeinstallprompt, which is dispatched on devices when a user is about to be prompted to "install" a web application. Its associated event may be saved for later and used to prompt the user at a more suitable time. 

Syntax

window.addEventListener("beforeinstallprompt", function(event) { ... });
window.onbeforeinstallprompt = function(event) { ...};

Example

The following example uses the beforeinstallprompt event handler to make an install button operable, by using the event inside a click handler.

window.addEventListener("beforeinstallprompt", function(e) {
  e.preventDefault(); // Prevents immediate prompt display

  // Shows prompt after a user clicks an "install" button
  installButton.addEventListener("click", function(e) {
    e.prompt();
  });

  installButton.hidden = false; // Make button operable
});

Specifications

Specification Status Comment
Web App Manifest
The definition of 'Window.onbeforeinstallprompt' in that specification.
Working Draft Initial specification.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome ? Edge ? Firefox ? IE ? Opera ? Safari ? WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ?

Legend

Compatibility unknown  
Compatibility unknown

See Also

ドキュメントのタグと貢献者

このページの貢献者: connorshea, wbamberg, samthor, jpmedley, chrisdavidmills, teoli
最終更新者: connorshea,