我读了this,this和this,但我认为我的情况不同。我不需要在每次调用AJAX时都刷新广告。
我有一个叫"mypage.php“的页面。当页面打开时,我将Adsense广告加载到第一个div。我的第二个div是空的。
在DOM完全加载之后,我创建了一个AJAX post。并将结果放入"lower_content“div。这会破坏Adsense TOS吗?
<body>
<div id="adSense_content>
<script> adsense script </script>
</div>
<div id="lower_content">
empty in start
</div>
</body>我的js文件:
$(document).ready(function() {
$.ajax({
type: "POST",
url: "/getit",
success: function(data) {
$("#lower_content").html(data);
}
});
}注意:为什么在页面打开时不加载第二个内容?因为AJAX调用在6-7秒内响应。当服务器负载较高时,即使在10-15秒内也会有响应。为了不让访问者在空页面上等待,甚至从页面上跳过。我在start中向访问者显示布局,并在AJAX调用的响应到来时加载内容。
编辑:把一个广告放在一个空页面上是不符合Adsense TOS的。但是在加载表数据时,我提到的页面是空的。在使用AJAX加载完整个表格之后,页面就加载了内容。但是在加载html页面的同时放置了广告。
发布于 2012-06-02 18:28:25
做了更多的研究..。你的问题没有简单的解决方案。
如果您的站点使用AJAX处理大部分内容,那么您可以考虑实现Google Ajax-Crawling (也称为Hash-Bang)规范。这将确保Google bot和Adsense bot抓取您的AJAX内容。这将对相关广告和搜索结果都有所帮助。https://developers.google.com/webmasters/ajax-crawling/docs/specification
或者,您必须等待Adsense for Ajax程序再次启动。https://developers.google.com/adsense-for-ajax/
更新:在经过更多研究后改变了答案。
发布于 2014-06-28 03:48:04
默认的google adsense代码是这样的:
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- banner-name -->
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-12345678901234950"
data-ad-slot="987654321"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>将代码分成3个部分,以使其在ajax加载的内容上工作。
在页面中的某个地方(例如,在您的页面中)只包含一次google脚本。
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>将google代码放在(ajax)内容中您想要横幅的任何位置
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-12345678901234950"
data-ad-slot="987654321"></ins>当您的内容通过ajax发生变化后,触发此函数。(不要忘了在页面加载时触发它,以便在页面不是通过ajax加载时显示广告。)
function displayGoogleAds(){
$('ins').each(function(){
(adsbygoogle = window.adsbygoogle || []).push({});
});
}Ps。我不确定google是否会允许这样做,因为你稍微修改了一下代码。但我目前正以这种方式使用它。
发布于 2013-12-15 07:39:31
不幸的是,页面https://developers.google.com/adsense-for-ajax/说谷歌不再接受AJAX的AdSense的新申请
https://stackoverflow.com/questions/10834751
复制相似问题