I have a js file test.js that contains the global variable global_var and a function fn1() that changes the global_var variable:
var global_var="initial_value"; function fn1(){ global_var="Value1"; alert("global_var="+global_var); }
then I execute fn1() from my page1.html, which sends me to page2.html:
<li><a href="page2.html" onclick='fn1();'></a></li>
Then in page2.html I want to use the global_var variable, but the continuous global_var does not change, it is "initial_value" !!
<script src="test.js"></script> <script> $('#mypage').live('pageshow', function(event) { alert(global_var); </script>
source share