I've read this question: Chrome Extensions & Javasctipy Database but I want an answer with more details and more clear.
How can I store some of my extension settings?
Is it possible to use a database to do such things with JavaScript?
Is there any good tutorial on it?
I don't want to use Local Storage, because I do not want the behavior of SESSIONS
Thanks.
You could use chrome.storage.sync or chrome.storage.local (docs). Both are local storage (not session storage); sync has the additional advantage that it syncs to the user's Google account if they've connected Chrome to it.
The following page lists the storage mechanisms in HTML5. WebSQL gives you a pretty good database for your javascript to use.
http://www.html5rocks.com/en/features/storage
UPDATE: It has been some time since I posted this. WebSQL has been dropped. Browsers will probably still continue to support it, but all the implementations have been SQLite. IndexedDB is the way to go now. I have used it and it is a little hard to get into, but works well for a client side database.
UPDATE AGAIN: Chrome changing things. See T.J. Crowder's Answer.
I believe this is a simple solution for you if you just want to save some settings. It also has some examples, hope it helps.
https://developer.chrome.com/extensions/storage.html
Related
I am writing a Quiz Application and require JavaScript mechanisms to temporarily store data without utilizing MySQL or an Internet Connection. The Game is a Standalone application. What techniques or libraries may be useful for such an application to store game data temporarily in the particular instance of running the JS functionality.
Please provide any references that may be useful.
Much appreciated
If you don't need your data to stay after you leave the page, consider using sessionStorage.
Otherwise, you're fine with localStorage, like I said in the comment, here is a very related answer: https://stackoverflow.com/a/26026430/965907
You can use cookies, but localStorage is a bit more modern and provides several advantages. See https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Storage for a list of storage options in modern browsers.
localStorage and sessionStorage are very similar, and I'd suggest you just use localStorage. See HTML5 Local storage vs. Session storage for a broader discussion.
Maybe you can use javascript cookies. With them you can keep information with a name for as long as you would like. sessionStorage and localStorage are harder to understand and add to your page, but if you are an expert then you could use those. But as I said, I would recommend using cookies.Good luck with your work!
With Javascript, exist some way to do a data repository (like the repository pattern for example), using the local storage of the browser? If exist, which compatibility issues between browsers will be found?
I believe this is what you are looking for:
http://coding.smashingmagazine.com/2010/10/11/local-storage-and-how-to-use-it/
It explains how to use the local storage on newer browsers(HTML 5 enabled) without the need for cookies.
I dont think it is possible to save data on browser storage.
other things you can do is using other ways to control that.
1st Way:
data you need to save for the entire session of the user you can globalize in your web by just declaring it as Global variable.
2nd Way
You can use the jQuery plugin called Cookie, you can find it in here
cookie will basically means saving for a longer term then the session. and it is ,in fact, saving data on the user's computer.
My personal suggestion : if you absolutely need to save data and a lot of it in a way, i would either suggest you to save it on your sever (if you have any) or by cookie.
If this answer wasn't enough satisfying for you, please comment and i will try to be more accurate and helpful.
I'm writing a cross/browser javascript "database explorer" that will allow me to look into local storage mechanisms. This should be a pretty handy tool for development. (Yes I'm aware that each browser has their own developer tools, but I want to create one that works across all browsers)
The question then is: how do I get a list of the databases that have been created in IndexedDB? And once I get that list, how can I open them without causing a change in version?
The answer is unfortunately simple: it isn't possible. And for privacy reasons it is a good thing that it isn't possible. The best way to make your database explorer is letting the developers pass the database name. I have written an indexeddbviewer my self, and I let the developer pass the db name in a data attribute. A blogpost shows you how you can use it, and the viewer is available on codeplex. And as last, I also have a demo of it.
I want to create an internally used web app that can be run with just a copy of the web app and the DB (anything from a text file to MS Access/Excel would work fine). Is this possible? I don't want users to have to setup a SQL server to get the app to work. Having the files necessary to run the web app stored on a shared network drive would be ideal, for example. The problem is that JS can't write to a DB. Is there anything that can use to do this?
Like mentioned, I can assume that Access/Excel are installed, if there's anything that might help there.
It's most certainly possible. W3 has put up the specs for a client side database that can be accessed by JavaScript. The modern browsers have good support for it, and since this is for an internal application, you would have some level of control I believe.
Checkout this slide that shows a live demo of Indexed Database. The full spec can be found here. See this link for browsers that currently support IndexedDB. Here's another set of slides showcasing how to use IndexedDB.
However, with this approach, each user's browser has its own DB locally. If you want a centralized DB, then you will need a server.
You can perform database transactions with JavaScript. This is generally discouraged, because it has terrible security implications. However, in a completely local environment, you are probably not causing any additional security risks. (Because, your database is already on the user's machine.) You can see an example of how to use ADO in JavaScript at How to connect to SQL Server database from JavaScript in the browser? .
Possible, yes, Like Making cars that can float in the sea but could not work on dry roads.
Use winforms or something similar. Use the right tool.
If you insists, Firefox plugins can behave in the way you mentioned, and there is a way to bundle a web application with it's server (check the beginner tutorials for RoR to have an example for something similar with webrick).
If I understand your requirements, you might look into ColdFusion.
For example, you can run a DB query pretty simply, check here, in Adobe
Does anyone know of a reliable way to store data to use across pages of a site?... Here is what I've found so far:
Cookies - Not enough capacity to store what I need atm.
URL hash - Same as above
Frames - Not a method I would use atm.
HTML 5 document.localStorage and document.sessionStorage - Not fully supported yet
Google Gears - The users of the site will most likely not have this installed
YUI Storage - This sounds promising... does anyone have experience using it?
jStore - This also sounds promising, but when I tried using the demo and reloaded the page, it lost my input. Does anyone have experience with this plugin?
Note: I am not an admin of the site in question, so I don't have database privileges, but I am able to add scripting.
Edit: I found this interesting site that saves session variables in the window.name... it probably has some security issues as well
Dojo has a cool plugin that uses flash for a local storage. Plus it abstracts it so if they have gears or an html5 browser it will use that instead
<input type="hidden"
store the value in it, the info comes back from the page together with the info, and after you send it to another page, and so on
Can you use server-sides sessions?