如何刷新 Google AdSense 内容

How to refresh Google AdSense content?

本文关键字:Google AdSense 内容 刷新 何刷新      更新时间:2023-09-26
<div name="googleAd">
 <script type="text/javascript">
            google_ad_client = "ca-pub-xxxxxxxxxxxxx";
            <!--/* BottomRight */-->
            google_ad_slot = "1781127922";
            google_ad_width = 180;
            google_ad_height = 150;
          </script>
          <script name="test" type="text/javascript"
                 src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
          </script>
</div>

我要将Google AdSense添加到我的页面,我想刷新它以查看其他广告。我怎样才能实现这个目标?我正在使用 XSLT。感谢您的帮助。

如果网页使用的是jQuery,只需实现以下代码:

$(".adsbygoogle").each(function(i,e){$(e).html($(e).html())});

而且,如果您想每 60 秒刷新一次,您可以尝试一个示例:

var ad_refresher = setInterval(function(){
        $(".adsbygoogle").each(function(i,e){
            $(e).html($(e).html())
        });
    }, 60000);

如果实现了上述代码,请使用以下命令停止刷新行为:

clearInterval(ad_refresher);

我建议您查看Google Adsense文档,如果允许您刷新广告。

如果您检查带有 Adsense 广告的网页的 DOM,您会看到一个 iframe。您可以找到 iframe,然后重新加载它

iframe.contentWindow.location.reload();

您可能需要调整内容才能使其完全正确。