How to save the state of a javascript variable that is used in multiple html pages

前端 未结 3 2030
执笔经年
执笔经年 2021-01-13 10:17

I am trying to make an application in phonegap. I have made a custom.js javascript file which have some functions as

function func1(){....}
function func2(){         


        
3条回答
  •  温柔的废话
    2021-01-13 10:33

    in modern browsers you can use localStorage for that

    var get = function (key) {
      return window.localStorage ? window.localStorage[key] : null;
    }
    
    var put = function (key, value) {
      if (window.localStorage) {
        window.localStorage[key] = value;
      }
    }
    

    use get and put to store value to the local storage of most modern browsers..

提交回复
热议问题