Is it possible to keep my javascript global variables after redirected to anothor page(in the same domain)?
I know i can use html5 localStorage/sessionStorage or store it on the server session state(and pull it later) . but when using complex or more then a few global variable, i wonder if there another quick way to use…
for example:
<html>
<head>
<title> first page </title>
<script type="text/javascript">
var myGlobal="this is my global variable";
...
</script>
</head>
<body>
...
<a href="secondPage.htm" ..> to the second page</a>
</body>
</html>
and in the secondPage.htm:
<html>
<head>
<title> second page </title>
<script type="text/javascript">
alert(myGlobal); //I want it to be : "this is my global variable";
...
</script>
</head>
<body>
...
</body>
</html>
No.
New page = new execution environment.
Those are pretty much the only options you have. Small amounts of data could be stored in cookies.