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
Example: Domain 1 - www.mydomain.com
<html>
<head>
<script type="text/javascript" src="http://www.example.com/app.js"></script>
</head>
</html>
Example App JS
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);
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 ?
Can this be done? And please no JQuery.