【问题标题】:How to refresh Google AdSense content?如何刷新 Google AdSense 内容?
【发布时间】:2013-01-16 14:53:12
【问题描述】:
<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。谢谢您的帮助。

【问题讨论】:

标签: javascript iframe adsense


【解决方案1】:

如果您检查带有 Adsense 广告的页面的 DOM,您会看到一个 iframe。你可以找到 iframe 然后用

重新加载它
iframe.contentWindow.location.reload();

您可能需要进行一些调整才能使其正常工作。

【讨论】:

    【解决方案2】:

    如果网页使用的是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 文档。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-02-13
      • 1970-01-01
      • 2019-02-05
      • 2016-02-21
      • 1970-01-01
      • 2018-08-26
      • 2011-06-21
      • 2015-05-01
      相关资源
      最近更新 更多