Call document.write ()
This code does not work:
<div class="pix"><div id="addTimestamp"></div></div>
<script type="text/javascript">
(function () {
var date = new Date(),
timestamp = date.getTime(),
newScript = document.createElement("script");
newScript.type = 'text/javascript';
newScript.src = 'someUrl=' + timestamp + '?';
document.getElementById('addTimestamp').appendChild(newScript);
}())
</script>
A dynamic script adds document.write(someCode which loads banners). But in Firebug I have an error:
The call to document.write () from an asynchronously loaded external script was ignored.
+5
3 answers
Add this:
newScript.async = false;
Your script must be loaded synchronously for it document.write()to work (see https://developer.mozilla.org/En/HTML/Element/Script#attr-async ). As you do now, the script will load whenever the browser has time for this, so you cannot know where your HTML will be inserted from document.write(). The browser decided to ignore your call document.write()to prevent the worst problems.
+4