title: Getting Javascript Domain When Script Is From Another Domain
body: <p>I am writing a script that is suppose to work across domains. I trying to include one script from another domain and then have that script include other scrips from the same domain</p>
  
  <p>Example: Domain 1 - <strong>www.mydomain.com</strong></p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
         &lt;script type="text/javascript" src="http://www.example.com/app.js"&gt;&lt;/script&gt;
      &lt;/head&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Example App JS</p>
  
  <pre><code>var imported = document.createElement('script');
  imported.src = window.location.host + 'config.js';
  document.head.appendChild(imported);
  
  var imported = document.createElement('script');
  imported.src = window.location.host + 'stuff.js';
  document.head.appendChild(imported);
  </code></pre>
  
  <p>The problem is window.location.host gives the domain that the script has been download to: www.mydomain.com . I wanted the domain that the script currently resides on, which is in this exmaple is www.example.com ?</p>
  
  <p>Can this be done? And please no JQuery.</p>