I have made a chrome extension, and I added a option page for it. I had a input on the option page like this <input id="inpID">
and did call a external javascript file like this <script type="text/javascript" src="whatever.js"></script>
The whatever.js
is like this:
var inpID = document.getElementById('inpID');
...
function getData(key){
var tem = '';
chrome.storage.local.get(key,function (msg){
tem = JSON.stringify(msg).substr((key.length+5),JSON.stringify(msg).length-(key.length+7));
})
return tem;
}
function setData(key,value){
chrome.storage.local.set({key: value},function(){});
}
...
inpID.addEventListener('keyup',saveID);
...
function saveID() {
setData('ID',inpID.value);
}
...
inpID.value = getData('ID')
However, this piece of code did not work at all. I type something in the input, refresh page, the input is still blank. Any helps?