2
<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を使用しています。助けてくれてありがとう。

4

2 に答える 2

5

Web ページが 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 のドキュメントを確認することをお勧めします。

于 2018-07-27T17:07:30.870 に答える
2

Adsense 広告が掲載されているページの DOM を調べると、iframe が表示されます。iframe を見つけてリロードできます

iframe.contentWindow.location.reload();

これを正確に機能させるには、微調整が必​​要になる場合があります。

于 2013-02-03T03:21:25.070 に答える