How to move an Iframe provided by an Ad provider to a different location on the page?

On my website I have ads that are provided by a third party.  However these ads have scripts in them that do a document.write.  I was trying to follow best practices in loading ads last on the page for performance reasons, so the ads are showing up at the bottom of my source, because of the document.write.  When I try to move the wrapper that contains the ad to the correct spot on the page, the ad is disappearing.  It looks like the ad has an IFrame within it so all the body and html of the iframe are disappearing.  Does anyone know how to move this without losing the data?
LVL 11
Jeffrey Dake Senior Director of TechnologyAsked:
Who is Participating?
 
Jeffrey DakeConnect With a Mentor Senior Director of TechnologyAuthor Commented:
mplungjan, Thanks for your feedback, but it looked like we were getting some race conditions when multiple ads were fired on the page.  

 COBOLdinosaur, we talked with our ad provider and I think we are just leaning toward switching ad providers.  They claim that they do not have an asynchronous solution, so looks like they are out.
0
 
dgrafxCommented:
can you provide a link please
0
 
Eddie ShipmanAll-around developerCommented:
How did you "move" the wrapper?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
COBOLdinosaurConnect With a Mentor Commented:
If the ad provider is using script within an iframe and the iframe content is host from the vendor's domain; then you are going to run into security violations if you try to modify using script.

You should be discussing the problem with the ad provider. First of all they can contol and can make changes if necessary, and secondly you might be violating you advertising contract if you try to modify any of their components.

Cd&
0
 
Michel PlungjanConnect With a Mentor IT ExpertCommented:
Here is how

<!DOCTYPE html>
<html>
<head>
<script>
var oldWrite = document.write;
var oldWriteLN = document.writeln;

var adText="";
document.write=function(str) {
  adText += str;
} 
document.writeln=function(str) {
  adText += str+"\n";
} 
window.onload=function() {
  document.getElementById("adWrapper").innerHTML=adText;
}
</script>
</head>
<body>
<div id="adWrapper">
<script src="http://someadserver.com/someadscript.js"></script>
</div>
</body>
</html>

Open in new window

0
 
Jeffrey Dake Senior Director of TechnologyAuthor Commented:
The guys lead me toward contacting the ad provider.
0
All Courses

From novice to tech pro — start learning today.