how do I assign a variable if 
<p>How do I write "assign a variable if a action happens". I'm writing the following but it always returns 1. Thank you</p>

<pre><code>function openwindow(){
testWindow = window.open("popup.php");
setTimeout(function() { testWindow.close(); },1000);
if(testWindow !== null){
    var t = 1;
    return t;
}
}
</code></pre>
