javascript - 如何刷新 Google AdSense 内容?

标签 javascript iframe adsense

<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 文档。

关于javascript - 如何刷新 Google AdSense 内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14643840/

相关文章:

javascript - 如何计算年龄?

javascript - 如何停止透​​明的 iframe 覆盖覆盖视频

Android WebView 固定元素不响应点击

.htaccess - 试图在 htaccess 中阻止点击轰炸机器人,但它仍然通过。我怎样才能永远阻止它?

javascript - Cypher 查询正则表达式以选择顶点和边

javascript - React-native IOS MapView 覆盖不显示

android - Android 浏览器问题上的 iframe

javascript - Three.js 通过 iframe 传递事件(onMessage)

asp.net - 如何将 googleAds 添加到我的网站?

javascript - 动画播放状态不适用于 Safari