var curline;
chrome.storage.local.get("value",function(item)
{
window.curline=item["value"];
});
alert(curline);
I want to set the curline
with item["value"]
,this code is in theinject.js
,thanks.
var curline;
chrome.storage.local.get("value",function(item)
{
window.curline=item["value"];
});
alert(curline);
I want to set the curline
with item["value"]
,this code is in theinject.js
,thanks.
chrome.storage API is asynchronous. The callback is executed later, after you alert.
Which means you must alert the result in the callback you pass :
var curline;
chrome.storage.local.get("value",function(item)
{
window.curline=item["value"];
alert(curline);
// here you may use curline, or pass it as argument to other functions
});