Subscribe

  • Subscribe  

Using Flash in JavaScript App to Store Data Locally

Posted by Charles | October 21, 2008 .

There are many reasons sometimes you want to store data locally to a user’s computer from a JavaScript application. JavaScript/HTML doesn’t have too much choice excepting using cookies. Of cause unless you use the more elaborate solution such Google Gear. Otherwise, the other option would be using Flash.

This Japanese dude create small JS/Flash utility you can use within a HTML/JS application to easily store local data.

You can download this utility from here. Once you unziip it you can play the test.html to see how it works.

To use it inside your application, copy these three files into you web app directory: swfobject.js ?save2local.swf ?save2local.js.

Then add these lines into your HTML page:

<script type=”text/javascript” src=”swfobject.js”></script>
<script type=”text/javascript” src=”save2local.js”></script>

After that, you can use it like this:

<script type=”text/javascript”><!–
function test() {
save2local.saveData(“key”,”value”);
alert( save2local.loadData(“key”) );
}
–></script>
<a href=”javascript:test()”>Just a test, click here .</a>

Flash allows to store 56k or more data locally by default. So you have some room here to play.

Leave a Comment

If you would like to make a comment, please fill out the form below.


Name

Email

Website

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Comments

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word


Related Posts

1 Comment so far
  1. Munawar  February 22, 2010 6:30 am

    Please suggest script to store data locally and access the stored values while opening a local file. The above save2local_js.zip works only online, but not from locally save file.

<

Direct TV Offers - usdirect has the best directtv deals