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

前端 未结 3 2045
执笔经年
执笔经年 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:37

    Store the values in localstorage and reference it from there.

    function first() {
        localStorage.setItem('myItem', "something you want to store");
    }
    
    function second() {
        myValue = null;
        if (localStorage.getItem('myItem')) {
            myValue = localStorage.getItem('myItem');
        }
    }
    

提交回复
热议问题