Getting the value of a variable from localStorage from a different javascript file

后端 未结 1 2042
你的背包
你的背包 2020-12-11 19:37

having a problem using localstorage in javascript. I have two javascript files and one multi-page html file. I\'m setting the value of a variable to store in local storage

相关标签:
1条回答
  • 2020-12-11 20:31

    This shouldn't be working at all. Its localStorage (JS is very case sensitive), and to save an item, you use setItem, change your syntax to:

    //You would not define var _NSCaseId and save the var, you save a string key
    localStorage.setItem('_NSCaseId', nsId); //set
    

    And to get

    localStorage.getItem('_NSCaseId');
    

    See DOM Storage: https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Storage

    0 讨论(0)
提交回复
热议问题