So essentially on page load I want to do the following:
<script>
$(document).ready(function () {
if (document.location.hostname == "somemachine.poc") {
var fileref = document.createElement('script')
fileref.setAttribute("type", "text/javascript")
fileref.setAttribute("src", "myscript.js")
}
});
</script>
In theory and practice is this correct? for some reason I put it on my page and it doesn't work as expected, and doesn't even show up in the source of the page.
So what I will end up doing is checking for several domains, dependent on which domain a different src for the .js will load.
UPDATE
The answers below helped me fix the issue, I have a new issue which follows on naturally from this question which can be found here: Losing entire page DOM running javascript