i'm looking for a way to use the same localStorage (or similar) for both http:// example
and https:// example
according to this, that's not possible using localStorage. there doesn't seem to be a globalStorage
for chrome though.
i'm doing this for a chrome extension, so using cookies is not an option and patibility with other browsers is not needed.
any ideas?
i'm looking for a way to use the same localStorage (or similar) for both http:// example .
and https:// example .
according to this, that's not possible using localStorage. there doesn't seem to be a globalStorage
for chrome though.
i'm doing this for a chrome extension, so using cookies is not an option and patibility with other browsers is not needed.
any ideas?
Share Improve this question asked Feb 28, 2011 at 16:11 user637980user637980 732 silver badges6 bronze badges 3- 1 Are you trying to read localStorage created by the site? Or you just trying to store some extension settings there? Also why cookies is not an option? – serg Commented Feb 28, 2011 at 16:20
- i'm trying to locally store (and keep track of) the time a user spends on a site that's not mine. i don't want to mess with the cookie of the site. i'm not that familiar with cookie use, so if you think that there's a possibility, go ahead :) – user637980 Commented Feb 28, 2011 at 16:24
- See also Is there any workaround to make use of html5 localstorage on both http and https?. – user456814 Commented Aug 13, 2013 at 19:43
1 Answer
Reset to default 5If all you need is store time spent on the site in localStorage then you don't need to solve this http/https problem. Extensions have their own isolated localStorage that you can access anytime anywhere, so just store your data there.
You can access this localStorage only from a background page, so from a content script you will need to send a request to a background page first and then work with localStorage there:
content_script.js:
chrome.extension.sendRequest({do: "save", value: "some_value"});
background.html:
chrome.extension.onRequest.addListener(function(request) {
if(request.do == "save") {
localStorage["param"] = request.value;
}
});
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744836793a4596311.html
评论列表(0条)