Search code examples
google-chrome-extensionxmlhttprequest

Chrome extension - wait popup until script is done


I am trying to make a Chrome extension, everything is going well, except that before the content of the popup is filled with javascript(XMLHttpRequest - asynchronous) I see a small blank popup that has not yet been filled.

That is,

Before this loads

I see this

In the code, I am simply using document.getElementById to fill up the HTML. So it looks like

HTML:

  <body>
    <div id="status"></div>
  </body>

JS:

document.getElementById('status').innerHTML = 'content of the request';

I see where this is coming from, since the popup is originally blank it shows that little blank box before javascript(XMLHttpRequest) is done. But How can I make it wait until the request is complete?


Solution

  • You can't manually display the browser/page action popup. This feature will not be implemented : source.

    The most simple solution is to add a loading wheel gif to the html of the popup. It will display the popup until the content is changed by your code when the request is complete.

    Another solution is to display a popup (not a browser/page action popup) when the user click on the browser/page action. This way you can wait for the request to display your popup.