开发者

Local Storage in HTML5

开发者 https://www.devze.com 2023-03-14 22:46 出处:网络
I am saving a value in the local storage (html 5) in page 1 and then开发者_如何学C when i go to page 2, the values in the localstorage are gone. Could you please let me know what could be the issue?

I am saving a value in the local storage (html 5) in page 1 and then开发者_如何学C when i go to page 2, the values in the localstorage are gone. Could you please let me know what could be the issue?

Editing

I am actually using the following functions to set the data on the local storage

function set(key, data) 
{ 
     localStorage.setItem(key, data); 
} 
function get(key) 
{ 
     return localStorage.getItem(key); } 
function remove(key) { 
     localStorage.removeItem(key); } 
function clear() { 
     localStorage.clear(); 
} 

I have issues getting it to work on Firefox and dont have any issues on Chrome. This looks like an entirely different issue. Thanks and Regards Abishek R Srikaanth


You don't provide enough detail to troubleshoot this properly, but check these things out:

  1. Are you previewing your design locally (e.g. via the file:// protocol), or are you on a proper web server? Only http:// requests will work accurately for you
  2. Local storage and Web SQL storage work by reference to the originating domain or IP address (again why point #1 is important): is your second page still in scope?
  3. What happens when you go back to page 1? Do the values re-appear?
0

精彩评论

暂无评论...
验证码 换一张
取 消