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, only 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.
Basically, a user inserts my script, lets call it my.js
(can't say what it is specifically at the moment.) my.js
is loaded and in my.js
some embedded media is displayed on their page then I need somehow to append the generated HTML from:
<script type="text/javascript"><!--
google_ad_client = "ca-pub-xxx";
/* my.js example Ad */
google_ad_slot = "yyy";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
Inside a specific <div>
(or whatever) element. Any ideas?
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 <div>
i named (I'm using Sizzle for my JS library if that helps)