title: Dynamic Adsense Insertion With JavaScript
body: <p>I can't believe how hard this is to find, but even in the Google developer docs I can't find it. I need to be able to dynamically, <em>only</em> with JavaScript insert adsense. I also looked on StackOverflow and some others have asked this but no response. Hopefully this will be a better explanation and will get some replies.</p>
  
  <p>Basically, a user inserts my script, lets call it <code>my.js</code> (can't say what it is specifically at the moment.) <code>my.js</code> is loaded and in <code>my.js</code> some embedded media is displayed on their page then I need somehow to append the generated HTML from:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;&lt;!--
  google_ad_client = "ca-pub-xxx";
  /* my.js example Ad */
  google_ad_slot = "yyy";
  google_ad_width = 468;
  google_ad_height = 60;
  //--&gt;
  &lt;/script&gt;
  &lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p>Inside a specific <code>&lt;div&gt;</code> (or whatever) element. Any ideas?</p>
  
  <p><em>P.S. No libraries like jQuery, and I can't insert HTML onto the page unless it's through JavaScript and it has to be inserted into a specific <code>&lt;div&gt;</code> i named (I'm using <a href="http://sizzlejs.com" rel="noreferrer">Sizzle</a> for my JS library if that helps)</em></p>