Skip to content

Wrapper that takes advantage of the power provided by HTML5 localStorage

License

Notifications You must be signed in to change notification settings

jjNford/html5-storage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTML5 Storage

An HTML5 local storage wrapper that adds the ability to save and retrieve objects from local storage.

How To Use

  1. Include the storage script in your project:

    <html>
    ...
    ...
    <body>
    	...
    	...
    	
    	<script src="libs/html5-storage/storage.js"></script>
    	
    	...
    	...
    </body>
    </html>
  2. Use window.storage to access the browsers local storage:

    function Person(name, gender) {
    	this.name = name;
    	this.gender = gender;
    }
    
    var user = window.storage.getItem("user");
    
    if(user === null) {
    	user = new Person("JJ Ford", "male");
    	window.storage.setItem("user", user);
    }
  3. Include attribution to library.

API

clear()

Clears browsers local storage.


getItem(key)

Retrieves the item associated with the given key from the browsers local storage.


isSupported()

Determines if the browser supports local storage.


length

Returns the size of the browsers local storage.


removeItem(key)

Removes the item associated with the given key from the browsers local storage.


setItem(key, data)

Saves the given data to the browsers local storage under the given key.

About

Wrapper that takes advantage of the power provided by HTML5 localStorage

Resources

License

Stars

Watchers

Forks

Packages

No packages published