I have a single html page with a large amount of content however, most of the content is hidden and only gets displayed when the user clicks a link in the sidebar and JQuery dynamically changes the content (div) being shown. I want an Adsense ad to be shown no matter which part of the content is being displayed but this would mean adding the adsense ad code into each hidden div. This wouldn't be a problem except it would mean that my single HTML page would have the same Adsense code pasted into 80 different places and I'm pretty sure this is against the Google Adsense TOS.
What would be the best, easiest way to have the ad shown in the same place no matter which div is currently being displayed and where I would only need to add the Adsense code ONCE!
BTW, Using a database to dynamically generate my content would be a sollution but I'm afraid its not an option in this case. Any suggestions?
You can have "placeholders" divs where you want the ad to appear and then put it dynamically, like this:
adsensecode = '...';
function div_show($div) {
$div.find('.adsense_placeholder').html(adsensecode);
}
function div_hide($div) {
$div.find('.adsense_placeholder').html('');
}
Just create one div containing Adsense adds, then since you allready work with JQuery you just append the adds-div to the view that currently is visible.
I guess you switch views with JQuery? At the same time as the view is changed you select the div with adds with JQuery, then you select the place in the view you want the add in and do a append() with JQuery.
Then you just repeat that for everytime the view is switched, then you'll only need one add-element.
If this is against their TOS I don't know, it could be since you display adds that google hasn't choosen for the current content.
If you google this questions you will also see that there is no "refresh api" for google adds so you can't reload the adds for the current content. Check the TOS, if you may do the above do it, else you will have to render the pages one by one with adds because there is no ajax support in adsense.
Regards
Tobias