简体   繁体   English

Chrome扩展程序HTML表单

[英]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. 我正在创建此Chrome扩展程序,当您单击当前页面上的按钮时,它将启动一个新的HTML页面,其中包含用户必须完成的某些输入字段。 The button is being triggered inside the content.js. 该按钮在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. 我想知道将用户在HTML表单中输入的信息检索回内容脚本的最佳/最简便的方法/或在表单中的“提交”按钮被按下后重写localStorage变量以在内容脚本中可用的方法是什么?按下。 Any thoughts would be highly appreciated! 任何想法将不胜感激!

As you have no code, this is purely guessing. 因为您没有代码,所以这纯粹是猜测。 Even so, I think chrome.storage.local would be useful. 即使这样,我认为chrome.storage.local还是有用的。

Here's an example from Google's Website: 这是来自Google网站的示例:

  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 . 如果您需要更多帮助, 请查看信息页面

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM