I wanted to include below script tag inside div dynamically.
<script type="text/javascript" src="http://ads.appnexus.com/ttj?id=12345678&cb=${CACHEBUSTER}"></script>
So I am able to do it by this way
document.write('\x3Cscript type="text/javascript" src="http://ads.appnexus.com/ttj?id=12345678&cb=${CACHEBUSTER}">\x3C/script>')
But I am not able to include it when I create it like
window.onload = function() {
var sNew = document.createElement("script");
sNew.type = 'text/javascript';
sNew.async = false;
sNew.src = "http://ads.appnexus.com/ttj?id=12345678&cb=${CACHEBUSTER}";
var s0 = document.getElementsByTagName('script')[0];
s0.parentNode.insertBefore(sNew, s0);
};
On Crome console it showing warning as
Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.
So what is wrong I done on above code. I wanted to include script Synchronously using document.createElement("script")