Post Loading ads - using appendChild to move an IFRAME with text link ads

Posted by Prem on Stack Overflow See other posts from Stack Overflow or by Prem
Published on 2010-05-12T01:16:00Z Indexed on 2010/05/12 16:24 UTC
Read the original article Hit count: 521

Filed under:
|
|
|

I have changed code around to basically load an add the bottom of the page in a hidden div and attached an onload event handler that called document.getElementById(xxx).appendChild() to take the hidden ad and move it into the right spot in my page. This works GREAT.. however when the ad is a text ad it AFTER i move the ad there is nothing in the rendered Iframe. I did tests to see what it looks like before i move it and sure enough the text links load in the IFRAME but the second i do the appendChild call to move the div that contains the ad i seem to loose the contents of the Iframe.

Any ideas whats going on

<div id="myad" style="display: none;">
    GA_googleFillSlot("MyADSlotName");
</div>

<script>
window.onload = function() {
    // leader board
    document.getElementById('adplaceholder').appendChild(document.getElementById('myAd'));
    document.getElementById('myAd').style.display = '';
</script>

UPDATE: I think what the problem here is that on text ads google writes to the iframe directly inserting the relevant text links where are on other ads it uses the iframe to just point to some src. seems like when i do the appendchild, if there is no "src" set for the iframe after the copy is done the iframe in the new location contains nothing... guess it does a reload on the src? Any way around this??

© Stack Overflow or respective owner

Related posts about iframe

Related posts about JavaScript