最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Google Chrome Extension Persistence - Stack Overflow

matteradmin8PV0评论

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!

Post a comment

comment list (0)

  1. No comments so far