0
  1. When I click the extension icon, a popup is shown.

  2. After that, when I try to click "URL restrictions", it will open a window, after that when I click the popup again, the popup is overlapping that url restriction window.

  3. The above issue happens on Windows only, not on Linux.

So I have added window.open('','_self').close(); which apparently fixed the issue. But not exactly. Is it correct? I have referred this Link and Link2 but can not understand the meaning.

What is the purpose of window.open('','_self').close();? EDIT: this is my popup.js

  function click(e) {


    var windowObj = window.open(site_exception_url, 'url_window', params);     
    windowObj.focus();
    window.close();
    window.open('','_self').close();
    return false;

}

Community
  • 1
  • 1
PHP dev
  • 410
  • 1
  • 7
  • 23

1 Answers1

1

On Windows the popup isn't closed automatically after a new window is opened from a link within the popup.

Close it in the click handler manually, this won't hurt Linux but will help on Windows:

document.addEventListener("click", function(event) {
    if (event.target.localName == "a") {
        close();
    }
});

The related questions linked in your question don't apply here as the first is for userscripts, not extensions, and the second isn't for popups shown by the browser when you click the toolbar button.

wOxxOm
  • 65,848
  • 11
  • 132
  • 136