browserSettings.allowPopupsForUserEvents

A BrowserSetting object that can be used to enable or disable the ability of web pages to open popups in response to user actions.

The underlying value is a boolean.

By default, browsers allow web pages to open popups in response to a particular set of events: for example, click, mouseup, submit. If allowPopupsForUserEvents is set to false, no user events will be able to open popups. If it is set to true, the default set of events will be allowed to open popups.

For example, suppose a web page has code like this:

js
window.addEventListener("click", (e) => {
  window.open("https://example.com", "myPopup", "height=400,width=400");
});

By default, this will open a popup window. If your extension sets allowPopupsForUserEvents to false, then it will not open a popup, and the user will be informed that the popup was blocked.

Examples

Toggle the setting:

js
function toggleAllowPopup() {
  function toggle(current) {
    console.log(`Current value: ${current.value}`);
    browser.browserSettings.allowPopupsForUserEvents.set({
      value: !current.value,
    });
  }

  browser.browserSettings.allowPopupsForUserEvents.get({}).then(toggle);
}

browser.browserAction.onClicked.addListener(() => {
  toggleAllowPopup();
});

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
allowPopupsForUserEvents
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 57 (Release date: 2017-11-14)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – Full support
Firefox for Android 57 (Release date: 2017-11-28)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support