How can I place an Adsense ad in each hidden JQuery div without exceeding their 3 ad limit

血红的双手。 提交于 2019-12-11 02:57:43

问题


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?


回答1:


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('');
}



回答2:


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



来源:https://stackoverflow.com/questions/8215530/how-can-i-place-an-adsense-ad-in-each-hidden-jquery-div-without-exceeding-their

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!