Note that there are some explanatory texts on larger screens.

plurals
  1. POCommunication between background page and popup page in a Chrome Extension
    primarykey
    data
    text
    <p>I'm currently trying to write an extension for Google Chrome, which can be used to upload files.</p> <p>There are two pages: the background page and the popup page. The popup page appears when you click the icon right of the omni-bar. You can specify the file you want to upload using the standard HTML <code>&lt;input type='file' ... /&gt;</code>.</p> <p>After selecting the file, and clicking "Upload", the name(+path) of the file should be sent to the background page. This, because the popup can be closed by the user by simply clicking somewhere else on the screen, which closes the page.</p> <p>When the popup is active, and the background page is uploading the file to the server, the popup should also recieve the progress of uploading(0-100%) from the background page, and display this information. When finished, the user should see the URL.</p> <p>The problem is, I don't know how to communicate between these two pages. The documentation isn't very clear about how this works. A thing I've tried, is making a function on the background page, called <code>upload(filename)</code>, and put this code in the popup page:</p> <pre><code>var BGPage = chrome.extension.getBackgroundPage(); BGPage.upload(the_filename); </code></pre> <p>But it didn't work, the function wasn't called.</p> <p>Does anyone know how I can send the filename from the popup page to the background page, and how to retrieve upload status(and eventually the link) from the background page, via the popup page?</p> <p>Thanks in advance!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload