I call a JavaScript script dynamically. Only worries, it is well known in the div in which I say but do not load in the div in which it is called at the bottom of my page.
Here is my code
PHP Code:
<div id='test'>
function calls_js() {
var newscript = document.createElement('script');
newscript.type = 'text/javascript';
newscript.onload = onLoad;
newscript.src = 'http://mysite.com/script.php?code=' + myvariable;
var head = document.getElementById('test');
//var head = document.getElementsByTagName('head')[0];
head.appendChild(newscript);
}
function onLoad() {
document.close();
}
calls_js();
</div>
result in my code:
PHP Code:
<div id='test'><script type='text/javascript' src='http://mysite.com/script.php?code=145228'></script></div>
but the result of the script appears at the end of my site and not in the div 'test'. I think it's linked to the onload event but I can not find a solution.
Bookmarks