I have this:
script_url = 'http://externaldomain.com/script.js'
div_id = 'div'+Math.floor(Math.random() * 1000000);
document.write('<div id="'+div_id+'"><scr'+'ipt id="banner-to-load"></scr'+'ipt></div>')
After DOM is ready i do this:
$('#banner-to-load').attr('src',script_url)
Now, script_url appended, but nothing happens. External script has some functions and document.write, but they don’t work. How can i run external script? Or if i run it document.write inside will rebuild my already compiled DOM?
Try setting src before you add it and recheck your script_url.
Update: Or make a cross domain Ajax Query. If you control the other page you can allow cross domain queries by setting the “Access-Control-Allow-Origin” header.