How to send a script from one page to another in JavaScript or jQuery?
<p>I would like to send some javascript from one file to another in my own server. For example on file 1 I have the following code:</p>

<pre><code>&lt;script&gt;

   alert("Hey There!");

&lt;/script&gt;
</code></pre>

<p>I want to send this code to file 2, so that the alert happens on file 2. Imagine File 2 had already loaded, I want to perform some processing on File 1 and based on the result of said processing I want to send something to File 2.</p>

<p>File 2 should not be sending any requests to File 1, File 1 should be doing all the sending, and File 2 should receive the message without page refresh.</p>

<p>Is this possible?</p>

<h2>EDIT</h2>

<p>Imagine I have 3 files (2 html and 1 js). File A has already loaded, there's nothing in there. The js file is call "sayHello.js", it has the following content:</p>

<pre><code>alert('Indeed 10 is less than 100');
</code></pre>

<p>File B has the following content:</p>

<pre><code>if (10 &lt; 100) {

   // attach the js file "sayHello.js" to File A

}
</code></pre>

<p>How would I be able to attach the js file to File A from File B (using the jQuery.getScript() method) and have the script execute on File A?</p>
