title: Global variable with jquery
body: <p>I have a js file test.js that contains a global variable <code>global_var</code> and a function <code>fn1()</code> that changes the variable <code>global_var</code>:</p>
  
  <pre><code>var global_var="initial_value";
  function fn1(){
      global_var="Value1";
      alert("global_var="+global_var);
  }
  </code></pre>
  
  <p>then I execute the <code>fn1()</code> from my page1.html that sends me to page2.html:</p>
  
  <pre><code>&lt;li&gt;&lt;a href="page2.html" onclick='fn1();'&gt;&lt;/a&gt;&lt;/li&gt;//this returns "global_var=Value1"
  </code></pre>
  
  <p>Then, in page2.html I want to use the variable <code>global_var</code>, but the continous of <code>global_var</code> is not changed, it's "initial_value"!!</p>
  
  <pre><code>&lt;script src="test.js"&gt;&lt;/script&gt;
  &lt;script&gt;
     $('#mypage').live('pageshow', function(event) {
     alert(global_var); //this returns "initial_value"!!! 
  });
  &lt;/script&gt;
  </code></pre>