4

ユーザーが「g+」ボタンをクリックしたときにページに警告メッセージを追加したいと思います。どうすればこれを達成できますか?
ここにコードがあります:

<g:plusone href="http://test.com//" annotation="inline" width="300"></g:plusone> 
<script type="text/javascript"> 
 (function() { 
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  })();
</script>
4

2 に答える 2

9

開始するコードが必要な場合に備えて、次のマークアップにより、+1ボタンでインタラクションイベントが有効になります。

<div
  class="g-plusone"
  data-expandto="bottom"
  data-onendinteraction="onEnded"
  data-onstartinteraction="onStarted"
  data-recommendations="false"
  data-annotation="inline"
  data-height="25"
  data-autoclose="true"
  data-callback="onCallback" 
  data-width="300"
>

次のコードはイベントを処理します。

function onStarted(args){
  console.log("started");
  console.log(args);
}
function onEnded(args){
  console.log("ended");
  console.log(args);
}
function onCallback(args){
  console.log("callback");
  console.log(args);
}

コールバックはボタンの+1状態を返し、開始/終了インタラクションはユーザー状態を示します。ここですべてのイベントのデモを見ることができます。

于 2013-01-24T18:27:44.867 に答える
2

実際には非常に優れたドキュメントを読んでみてください。コールバック関数へのアクセスを提供します。セクションを参照してくださいtag attributes

https://developers.google.com/+/plugins/+1button/#script-parameters

于 2013-01-20T05:01:08.687 に答える