We are using window.confirm() in the JS parts of Lightning Aura Components and embedded Visualforce pages (iframed).

This worked just fine for several years.

Yesterday I noticed that in both use cases some suppression has started to kick-in: when I click on something which is invoking window.confirm() and only proceeds when the user clicks "Yes", simply nothing happens. No popup is showing up. Hence, no "Yes" could ever be clicked. Leading to broken functionality :-(

Now it comes: this happens only sometimes - not always. I've found no reproducible example. It feels actually just random. Same code, even the same record, same browser, same settings - I would say same everything. Sometimes it works, sometimes it does not... strange... it feels like quantum physics...

Inspecting the console, I found this (in case it does not work):

Ignored call to 'confirm()'. The document is sandboxed, and the 'allow-modals' keyword is not set.

So sometimes it looks like this (unwanted and harming behaviour):

enter image description here

But should look like this:

enter image description here

I know that alert() popups are not the very best way to interact with the user. On the other hand they are also not that bad and especially via iframed Visualforce page it is by far the easiest way to tunnel a popup to LEX. Also for silly Yes | No questions, window.confirm() is mostly good enough to rock the show.

So why this started to happen?

And why it works sometimes and sometimes it bugs?

  • 1
    The information/error message you get on console seems a problem with iFrame's in general and is not lightning specific, have you tried adding sandbox="allow-scripts allow-modals" as mentioned here?.
    – Raul
    Jun 4 '19 at 14:32
  • 1
    @Raul Generally,you don't have access to the iFrame so you can't set properties of it. The iFrame is provided by sfdc automatically. I suppose one theory would be to put an iFrame inside the VF page and set the properties of that iFrame. I have no idea if that would actually work though.
    – gNerb
    Jun 4 '19 at 15:44
  • @raul not true. im getting this on a lightning component, too. reasons unclear. as a matter of fact, what you see in the screenshot is a lightning aura component v36
    – Uwe Heim
    Jun 4 '19 at 21:01
  • @gNerb not necessarily true: yes, there is a standard salesforce component to embed visualforce components, but as you said you have no access to the properties and the component is very unflexibel. As a result my very first lightning component was a way more powerful container for visualforce pages. but since the error 100% certainly also happens for pure lightning components, I seriously doubt that it would have any impact either.
    – Uwe Heim
    Jun 4 '19 at 21:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.