最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Google Chrome Extension Persistence - Stack Overflow

programmeradmin2浏览0评论

My question is quite simple, i need to develop a Google Chrome Extension and by the way create dynamically HTML/CSS files. Basically i was thinking to do this with javascript but it's not possible for security reason. So i'm thinking about using directly Chrome API.

Is there a persistance API with chrome ?

My question is quite simple, i need to develop a Google Chrome Extension and by the way create dynamically HTML/CSS files. Basically i was thinking to do this with javascript but it's not possible for security reason. So i'm thinking about using directly Chrome API.

Is there a persistance API with chrome ?

Share Improve this question edited Oct 7, 2012 at 19:07 vurquee 4911 gold badge7 silver badges20 bronze badges asked Mar 8, 2011 at 15:04 SindarSindar 10.9k7 gold badges34 silver badges45 bronze badges 5
  • 2 Question may be simple, but I don't really get what you're asking... – Bart Commented Mar 8, 2011 at 15:13
  • I don't understand "it's not possible for javascript reason." why is it not possible? Google Chrome API for extensions must be consumed using javascript. – apose Commented Mar 8, 2011 at 15:14
  • Sorry i've edited the post... The question is just that i wan't to know how i can write a file... Using Chrome API, HTML5, js, jquery ? What's the best possibility... – Sindar Commented Mar 8, 2011 at 15:15
  • I don't know if it this is pletely what you need but it is worth a look: robertnyman./2010/04/22/… – apose Commented Mar 8, 2011 at 15:28
  • 1 Could you please explain in more details why do you need this and what kind of task are you solving. – serg Commented Mar 8, 2011 at 17:07
Add a ment  | 

3 Answers 3

Reset to default 2

Chrome Extensions use localStorage for data persistence. Check out http://diveintohtml5.ep.io/storage.html for a tutorial.

Note that only strings can be saved to localStorage. You'll need a JSON parser/stringifier if you want to load/save objects.

It is possible to do this with javascript. Chrome is very strict when it es to calling scripts outside its domain(your extension folder I mean). 1. Make sure you are making js calls from your background page and not your content scripts. 2. If you are making js/ajax calls, note that chrome always sends an OPTIONS request. even for GET requests. So your server have to be able to grant permisions.

I hope these 2 points help your js. However, as everyone is saying, LocalStorage does a really good job.

I'm not pletely sure of what you are asking but take a look at Local Storage

Hope it helps!

发布评论

评论列表(0)

  1. 暂无评论