📕
blog
  • Hi there
  • javascript
    • 柯里化 - Curry
    • 观察者和订阅-发布模式
    • generator
    • 发布订阅-依赖于window
    • pwa manual trigger install
  • browser
    • beautify scrollbar
  • http
    • nginx 缓存配置
  • extra
    • vue-cli 不使用 .env[.xxx] 文件,添加额外运行时参数
    • docker-compose nginx with ssl config
  • React
    • How React works
Powered by GitBook
On this page

Was this helpful?

  1. javascript

pwa manual trigger install

window.addEventListener('beforeinstallprompt', e => {
    if (window.matchMedia('(display-mode: standalone)').matches) {
        // don't display install banner when installed
        return e.preventDefault();
    } else {
        const btn = document.querySelector('#install')
        btn.hidden = false;
        btn.onclick = _ => e.prompt();
        return e.preventDefault();
    }
});

Previous发布订阅-依赖于windowNextbeautify scrollbar

Last updated 4 years ago

Was this helpful?