I have attached an event to a text box using addEventListener. It works fine. My problem arose when I wanted to trigger the event programmatically from another
addEventListener
var btn = document.getElementById('btn-test'); var event = new Event(null); event.initEvent('beforeinstallprompt', true, true); btn.addEventListener('beforeinstallprompt', null, false); btn.dispatchEvent(event);
this will imediattely trigger an event 'beforeinstallprompt'