Dynamically add script tag with src that may include document.write
var my_awesome_script = document.createElement(‘script’); my_awesome_script.setAttribute(‘src’,’http://example.com/site.js’); document.head.appendChild(my_awesome_script);
var my_awesome_script = document.createElement(‘script’); my_awesome_script.setAttribute(‘src’,’http://example.com/site.js’); document.head.appendChild(my_awesome_script);
Use content:url(“image.jpg”). Full working solution (Live Demo): <!doctype html> <style> .MyClass123{ content:url(“http://imgur.com/SZ8Cm.jpg”); } </style> <img class=”MyClass123″/> Tested and working: Chrome 14.0.835.163 Safari 4.0.5 Opera 10.6 Tested and Not working: FireFox 40.0.2 (observing Developer Network Tools, you can see that the URL loads, but the image is not displayed) Internet Explorer 11.0.9600.17905 (URL never loads)
Give your img tag an id, then you can document.getElementById(“imageid”).src=”https://stackoverflow.com/questions/11722400/template/save.png”;