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是的,在我的經驗,這一直工作。 –