Redirect document.write from javascript script
<p>We want to serve ads on our site but the adserver we are in talks with has issues with delivering their advertising fast enough for us.</p>

<p>The issue as I see it is that we are supposed to include a <code>&lt;script src="http://advertiserurl/myadvertkey"&gt;&lt;/script&gt;</code> where we want to display the ad and it will then download a script and use document.write to insert some html.</p>

<p>Problem is that the call to the advertiser website is slowish and the code returned then downloads another file (the ad) which means the speed of rendering our pages slows while we wait for the request to be filled. </p>

<p>Is there a way to take the output from the document.write call and write this in after the page has loaded?</p>

<p>Basically I want to do this:</p>

<pre><code>&lt;html&gt;
&lt;body&gt;

    &lt;script&gt;
function onLoad() {
    var urlToGetContentFrom = 'http://advertiserurl/myadvertkey';

    // download js from above url somehow

    var advertHtml = // do something awesome to interprete document.write output
    $('someElement').innerHTML = advertHtml;
}
    &lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Or anything similar that will let me get the output of that file and display it.</p>
