how to keep javascript window.open variable reference
<p>I have a requirement that I need to create a link to open a form in a new window and then when I click the same link it will focus on the existing window again. </p>

<p>this works well with the following code </p>

<pre><code>&lt;input type="button" value="Click" onclick = "return OpenWindow();"/&gt;

&lt;script&gt;
var win = null;
function OpenWindow()
{
   if (win == null || win.closed)
   {
      win = window.open('http://localhost/Conditions.aspx', 'Condition');
   }
   win.focus();
   return false;
}
&lt;/script&gt;
</code></pre>

<p>However, I experienced a problem, when I switch to different page and come back to the page which has the link. the variable <code>win</code> will not retain the previous reference. 
If I click the link again, it will refresh the existing window (which is not what I want!) and then focus on it.</p>

<p>Is there any way that I can keep variable reference? or does anyone know how to solve this problem?</p>
