MDN wants to learn about developers like you: https://qsurvey.mozilla.com/s3/MDN-dev-survey

BeforeInstallPrompt

这篇翻译不完整。请帮忙从英语翻译这篇文章

 

非标准
该特性是非标准的,请尽量不要在生产环境中使用它!

在一个用户被提示”安装“一个网站到移动设备的一个主屏幕之前,  BeforeInstallPromptEvent Window.onbeforeinstallprompt 处理程序触发。

该接口继承自Event接口。

Constructor

new window.BeforeInstallPromptEvent(name, eventInitOptions)
Creates a new BeforeInstallPromptEvent.

Properties

Inherits properties from its parent, Event.

BeforeInstallPromptEvent.platform 只读
Returns a DOMString containing the platform on which the event was dispatched.
BeforeInstallPromptEvent.userChoice 只读
Returns a Promise that resolves to a DOMString containing either 'installed' or 'dismissed'.

Methods

BeforeInstallPromptEvent.prompt() 
Allows a developer to show the install prompt at a time of their own choosing. This method returns a  Promise.

Example

window.addEventListener("beforeinstallprompt", function(e) { 
  // log the platforms provided as options in an install prompt 
  console.log(e.platforms); // e.g., ["web", "android", "windows"] 
  e.userChoice.then(function(outcome) { 
    console.log(outcome); // either "installed", "dismissed", etc. 
  }, handleError); 
});

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support

44.0 [1]

未实现 未实现 未实现 未实现
prompt() method. 45.0 [1] 未实现 未实现 未实现 未实现
Feature Android Android Webview Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support 未实现

44.0 [1]

未实现 未实现 未实现 未实现

44.0 [1]

prompt() method. 未实现 45.0 [1] 未实现 未实现 未实现 未实现 45.0 [1]

[1] Behind the flagchrome://flags/#bypass-app-banner-engagement-checks

文档标签和贡献者

标签: 
 此页面的贡献者: xgqfrms-GitHub, marcoscaceres
 最后编辑者: xgqfrms-GitHub,