Showing posts from August, 2011

How to use HTML5 local store?

I have prepared a small example which show how to use HTML local storage feature. The concept is similar to cookies, but it’s designed for larger quantities of information. Cookies are limited in size, and your browser sends them back to the web server every time it requests a new page which takes extra time and precious bandwidth.

<!DOCTYPE html>

function putInLocalStore(){
    localStorage.setItem("comments", document.getElementById("comments").value);

function getFromLocalStore() {
    var data = localStorage.getItem("comments");
    var comments = document.getElementById("comments");

    comments.value = (data != "") ? data : "";

function pageOnLoad(){

    <body onLoad="pageOnLoad();">
        Enter data to put in local store: <input id="comments" type="text" >