javascript - same localStorage for http and https? - Stack Overflow

i'm looking for a way to use the same localStorage (or similar) for both http: exampleand http

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
Add a ment  | 

1 Answer 1

Reset to default 5

If 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

相关推荐

  • javascript - same localStorage for http and https? - Stack Overflow

    i'm looking for a way to use the same localStorage (or similar) for both http: exampleand http

    2天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信