0

我创建此Chrome扩展,它当您单击当前页面上的一个按钮,启动一个新的HTML页面输入一些字段,用户必须完成。该按钮正在content.js中触发。我想知道什么是最好/最简单的方法来检索用户在HTML表单中输入的内容脚本的信息/或者在表单中的提交按钮之后覆盖localStorage变量以便在内容脚本中可用按下。任何想法将不胜感激!铬扩展HTML表单

+2

没有代码,您的问题可能会被降低或关闭。但基于我所猜测的最好的方法将使用'chrome.storage.local'。 – wOxxOm

回答

0

由于您没有代码,这完全是猜测。 即便如此,我认为chrome.storage.local将是有用的。

下面是一个例子,从谷歌的网站:

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'); 
    }); 
    } 

如果您需要更多的帮助,check out the info page

+0

因此,如果我保存使用弹出html页面内的本地存储,它会保存在content.js内吗? –

+0

@MarcZaharescu是的,在我的经验,这一直工作。 –