I want to display an advertisement in my page loaded with AJAX/jQuery-JSON.
- The script:
- The file xxxxx.js contains a document.write ();
How to integrate this script and make the document.write be interpreted. and why it does not work?
here is my test revealed that the script is executed because the alert ('hello 1') is displayed but not document.write that contains the alert ('hello 2');
Call the file directly into the DOM execute well "hello 1" and "hello 2"
test.js
alert("hello 1");
document.write('<scr'+'ipt type="text/javascript">alert("hello 2");</scr'+'ipt>');
index :
<body>
<script>
function loadScriptJs() {
var s = document.createElement('script');
s.src = 'test.js';
s.type = 'text/javascript';
document.getElementById("pub").appendChild(s);
}
</script>
<div id="pub">
PUB A AJOUTER CI DESSOUS EN JAVASCRIPT :
<!-- appel direct de la pub
<script src="test.js" type="text/javascript"></script> -->
</div>
<script> loadScriptJs(); </script>
</body>