cookie或带有Chrome扩展程序的localStorage [英] cookie or localStorage with chrome extensions

查看:257
本文介绍了cookie或带有Chrome扩展程序的localStorage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读所有其他q在这里关于主题,但不能解决我的问题。

我在我的网站设置用户的电子邮件在localStorage,我想检索

I've read all the other q's here regarding the topic but couldn't solve my problem.
I'm setting on my website the email of the user in the localStorage and i want to retrieve it in the extension.

localStorage.setItem("user", "andrei.br92@gmail.com" ); 

但是当我尝试使用chrome扩展程序接收它时,无法这样做

But when i try to receive it with the chrome extension it fails to do so

value = localStorage.getItem("user");

哪种方式更容易? cookie localstorage?

Which way is easier ? cookies localstorage ? im not pretentious

推荐答案

请参阅:

http://code.google.com/chrome/extensions/content_scripts.html#host-page-communication

内容脚本在单独的JavaScript世界中运行,这意味着内容脚本的 localStorage 不同从网站的 localStorage 。唯一的两个共同点是DOM,所以你需要使用DOM节点/事件来沟通。

Content scripts are run in a separate JavaScript world, which means the content script's localStorage is different from the website's localStorage. The only thing the two share is the DOM, so you'll need to use DOM nodes/events to communicate.

这篇关于cookie或带有Chrome扩展程序的localStorage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆