Problems with using window.confim

Michael Buckley support at codefisher.org
Sun Oct 1 09:11:53 UTC 2017


Hi All,

I am trying to call window.confirm before doing an action. However I am 
running into a lot of problems when doing so.  I want to do so inside a 
browserAction panel.  So something like this:

async function doAction() {
     let items = await browser.storage.local.get({
         should_confirm: true
     });
     if (!items.should_confirm || window.confirm("Should we really")) {
         // Do something
     }
     window.close();
}

The code I put in side fails with an error like "TypeError: can't access 
dead object[Learn More]" since once window.confirm is called the panel 
closes.

I have tried ways around it, but with no success.  I tried using 
browser.runtime.connect to try and move the action to the background 
script, but that failed.  The port is either dead when I want to call 
it, or if I try and put the window.confirm in the background script, 
well that is not permitted.

Is there any way to do this?  Or is there a better way of getting the 
user to confirm?

Regards
Michael



More information about the Dev-addons mailing list