I have a web app, which has 2 html pages(html1,html2 related to javascript file js1.js,js2.js)
When I click a button on html1, it will navigate to html2.
I know there is the way transfer the parameter using url from html1/js1/js to html2/js2.js.
Is there a mechanism that set up variables both j1.js j2.js can access?(likes global variable in c)
Welcome any comment?
A hackish solution is to store it into the window.name field. This is shared in the same window/tab of the browser.
I personally don’t like it. That variable isn’t meant to be used this way.
There are libraries to persist state: http://pablotron.org/?cid=1557
Or, you could write your own code to store the variable in session (requires server-side programming), in HTML5 storage, in cookies, etc.