How to execute functions defined in parent window with child window context
<p>I have two windows: parent and child(html page and iframe).</p>

<p>I have a script library loaded to parent window.</p>

<p>I want to reuse this library from child window without loading the same script into child window.</p>

<p>It is easy to call functions of parent window like this: </p>

<pre><code>    top.LibraryMethod();
</code></pre>

<p>But there is a problem here: LibraryMethod will be executed with execution context of parent window. 
This means that global variables used in the script will be collected from parent window, instead of child window. 
For example, if LibraryMethod is declared as following:</p>

<pre><code>    function LibraryMethod(){ alert(document.location.href); }
</code></pre>

<p>It will show the same value being called from parent or child window, but I need access here the document of child window.</p>

<p>There is an obvious solution - pass child window as function parameter, but this required to change library code, that is not acceptable.</p>

<p>So, the question is how to access the child window object from a function declared in parent window, if this function is called from child window, without introducing additional function parameters.</p>
