Sett scope on javascript function call
<p>I want to call a javascript function within a protected scope and i can do it this way   </p>

<pre><code>var a = "Global a";
( function() {
    var a = "Local a";
    var alertA = function() {
      alert(a);
    }
    alertA(); 
})();
</code></pre>

<p>This alerts "Local a" butt what i realy would like to do is to get the same result with an already declared function. </p>

<pre><code>var a = "Global a";
var alertA = function() {
    alert(a);
}

( function() {
    var a = "Local a";
    alertA(); 
})();
</code></pre>

<p>So my question is how can a call alertA with a different scope so the result would be "Local a"</p>

<p>The reason i would like to do this i want to call globally defined functions on different iframes and have global variabels like document and window point to the appropriate documents and windows for every specific iframe.</p>
