I want to load external javascript file but I can’t use AJAX requests because of same origin policy, and I have a code:
<script type="text/javascript">
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'test.js';
head.appendChild(script);
</script>
That is ok everywhere (Firefox, Chrome, Opera, IE9, IE6) but not in IE8, IE7.
How can I make it work in IE8?
How about the old
document.write('<script language="javascript" src="test.js"><\/script>'). Also you do not have to append toheadyou can usebodyto.