I have a web site which downloads the same script from any number of different servers:
<script type="text/javascript" src="http://server1.example.com/hello.js"></script>
<script type="text/javascript" src="http://server2.example.com/hello.js"></script>
<script type="text/javascript" src="http://server3.example.com/hello.js"></script>
<script type="text/javascript" src="http://server4.example.com/hello.js"></script>
Each script has a locally-scoped variable which has to be the hostname of the server that script was downloaded from: so when I download the script from server1.example.com
that variable's value has to be server1.example.com
.
Can this be done with absolutely no server-side programming? (AJAX requests can be sent, but the solution cannot include any server-side code)
Please note that I am looking for the host which the script is hosted on, not the host of the current browser page; that means I am not looking for window.location
.