Is there any way to stop an Iframe re-loading it\'s contents when I change it\'s position within the DOM? Simple example:
Considering the simplicity of your test case, it looks like the only methods you have available to put an element inside another will always force the contents to reload.
[Edit] After seeing what you're trying to do, there are a couple things you can try:
What about using an ajax request to load the ad's contents, and adding the contents to the DOM when the ajax call returns, instead of using an iframe?
I'm regretting my original answer, as it seems to be causing other headaches. Here's a few other potential solutions that you may not have tried:
display
style set to none
. Then, move them to their final desintation and change them to display: block
after the page has loaded. Perhaps this would prevent the iframe
s from loading their content inititially.visibility
set to hidden
, then changed to visible
.A quick guess would be to unset the value of the src attribute of the iframe element or set it to "about:blank".
It is up to you to restore the previous value (or any value) to the src attribute of the iframe (using JavaScript).
Regards,
If the ads are a fixed size, you could place them in absolutely-positioned divs instead. Then, once the page loads, you could move those container divs to their designated spots. There are a lot of Javascript samples out there for calculating an absolute position from a relative position. Of course, you would have to reserve space visually in the destination divs so the ads wouldn't cover the content.