Marc Zaharescu
Marc Zaharescu

Reputation: 639

Chrome-Extension HTML form

I am creating this Chrome-Extension, which when you click a button on the current page, launches a new HTML page with some input fields the user has to complete. The button is being triggered inside the content.js. I was wondering what would be the best/easiest way to retrieve the information the user has input in the HTML form back to the content script/ or override the localStorage variables to be available in the content script after the submit button in the form has been pressed. Any thoughts would be highly appreciated!

Upvotes: 0

Views: 947

Answers (1)

its_notjack
its_notjack

Reputation: 323

As you have no code, this is purely guessing. Even so, I think chrome.storage.local would be useful.

Here's an example from Google's Website:

  function saveChanges() {
    // You'd get a value from your form here.
    var theValue = textarea.value;
    // CCheck there's actually something there
    if (!theValue) {
      message('ERROR - There's nothing here');
      return;
    }
    // Now use the Chrome Storage API to save the settings
    chrome.storage.sync.set({'value': theValue}, function() {
      // Success! Let's log a message.
      message('Settings saved');
    });
  }

If you need more help, check out the info page.

Upvotes: 2

Related Questions