Get stored input data form window.localstorage when browser is closed suddenly ,Few scenario i cant able to get data

Get stored input data form window.localstorage when browser is closed suddenly ,Few scenario i cant able to get data

Test1 = <input type='text' title='Tags' id='tags' name='test1' /> <br/> Test2 = <input type="text" id="idfield1" name="test2"> <br/> Test3 = <input type="text" id="idfield2" name="test3"> <br/> Test4 = <textarea id="tr" name="test4"></textarea>

script :

$(document).ready(function() { var aTags = ["ask", "always", "all", "alright", "one", "foo", "blackberry", "tweet", "force9", "westerners", "sport"]; $("#tags").autocomplete({ source: aTags }); }); $('#idfield1').keypress(function() { $('#idfield2').val($(this).val()); }); (function(window, document, undefined) { function changeSelect(event) { if (event.target.type == 'checkbox' || event.target.type == 'radio') { window.localStorage.setItem(event.target.id, event.target.checked ? 'checked' : 'unchecked'); } else { window.localStorage.setItem(event.target.id, event.target.value); } } function load(event) { var i = 0, k, e; while (i < window.localStorage.length) { k = window.localStorage.key(i++); e = document.getElementById(k); if (e) { if (e.type == 'checkbox' || e.type == 'radio') { e.checked = window.localStorage.getItem(k) == 'checked'; } else { e.value = window.localStorage.getItem(k); } } } } function clearData(event) { window.localStorage.clear(); } window.addEventListener('load', load, true); window.addEventListener('change', changeSelect, true); window.addEventListener('select', changeSelect, true); window.addEventListener('keyup', changeSelect, true); window.addEventListener('click', changeSelect, true); window.addEventListener('submit', clearData, true); })(window, document)

I want to Get input data form window.localstorage when browser is closed suddenly ,Few scenario i cant able to get data

I can able to get input data in some scenarios .According to my example test 1 and test 3 cant able to get data .

Just type the data in test1,test2,test3,test4 and please reload page you see that test1 and test3 cant able to retrieve same data

This are the same scenarios which i had used in production . Here is the fiddle to test http://jsfiddle.net/kxc156ox/

Please help me if any one of you used this kind of scenario .

Thanks in advance .