扩展名:chrome.storage SET [英] Extension: chrome.storage SET
问题描述
大家好:
我的另一篇文章,我们解决了GET。
好吧,我再次获得了基础工作 - 我想。
现在我真的不知道chrome存储的SET命令是如何工作的。
这应该设置/保存包含该ID的框中的值:ts_id_js_html
var input_id = document.getElementById(ts_id_js_html).value;
chrome.storage.local.set({ts_id_js:input_id});
这是它应该从以下位置获得值的地方:
< form>
< input id =ts_id_js_htmltype =textvalue =128856>< / input>
< button id =execButton>保存/加载< /按钮>
< / form>
>
chrome.storage.local.set({ts_id_js:input_id},function(obj){chrome.storage.local.get(ts_id_js ,function(obj){console.log(ts_id_js INSIDE func。test(this is your ID?):+ obj.ts_id_js); //这行代码用于控制台的测试输出});
现在唯一的问题是,由于某种原因它无法在Chrome扩展弹出框中获得输入。每当我尝试获取ID时,都需要先添加
chrome.storage.local.get(ts_id_js,function(obj){
代码前,然后在最后关闭它
(如果有人使用此代码,请不要忘记更改所有必需的部分! / p> Hello everyone :) my other post where we solved the GET.
Ok, I got the base working once again - i think.
Now I really don't know how the SET command of chrome storage works. This should set/save the value that is in a box with this ID: "ts_id_js_html" This is where it (should)get the Value from:
I actually got it working with this: Only issue now is, that it fails to get the input in the chrome extension popup for some reason. Whenever I try to GET the ID I need to first add infront of the code, and then close it at the end (if someone else uses this code, DON'T forget to change all parts that are necessary! (ts_id_js, input_id, obj (obj.ts_id_js)) 这篇关于扩展名:chrome.storage SET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!}); $ c $ (ts_id_js,input_id,obj(obj.ts_id_js))
var input_id = document.getElementById("ts_id_js_html").value;
chrome.storage.local.set({"ts_id_js": input_id});
<form>
<input id="ts_id_js_html" type="text" value="128856"></input>
<button id="execButton">Save/Load</button>
</form>
chrome.storage.local.set({"ts_id_js": input_id}, function (obj) { chrome.storage.local.get("ts_id_js", function (obj) { console.log("ts_id_js INSIDE func. test (is this your ID?):" + obj.ts_id_js); //this line is for test output in console });
chrome.storage.local.get("ts_id_js", function (obj) {
});