HTML5 local storage

by Alin Guta

HTML

<!--1-->
<div data-role="page" id="firstpage">
  <div data-role="main" class="ui-content">
    <h1>Page 1</h1>
    <a href="#secondpage" data-role="button" onclick='storageValue();'>Store and next</a>
      
    <a href="#firstmage" id="resume" data-role="button">Continue</a>
  </div>
</div>
<!--2-->
<div data-role="page" id="secondpage">
  <div data-role="main" class="ui-content">
    <h1>Page 2</h1>
    <a href="#thirdpage" data-role="button" onclick='storageValue();'>Store and next</a>
    <a href="#firstpage" data-role="button" >Back to page 1</a>
  </div>
</div>
<!--3-->
<div data-role="page" id="thirdpage">
  <div data-role="main" class="ui-content">
    <h1>Page 3</h1>
    <a href="#fourthpage" data-role="button" onclick='storageValue();'>Store and next</a>
    <a href="#firstpage" data-role="button" >Back to page 1</a>
  </div>
</div>
<!--4-->
<div data-role="page" id="fourthpage">
  <div data-role="main" class="ui-content">
    <h1>Page 4</h1>
    <a href="#" data-role="button" onclick='storageValue();'>Store</a>
    <a href="#firstpage" data-role="button" >Back to page 1</a>
  </div>
</div>
            
<script>
function storageValue() {
    var stored = $.mobile.pageContainer.pagecontainer("getActivePage").attr('id');
    alert("Your stored id is: " + stored);
    
    localStorage.setItem('stored', stored);
    checkLocalStorage();
    
    
}
var test = localStorage.getItem('stored');
var resume = "#" + test;
alert("Your stored id is: " + resume);

checkLocalStorage();

</script>