Attach the click () event to the google plus button?

I want to add a warning message to the page when the user presses the "g +" button. how can i achieve this
here is the code:

<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
source share
2 answers

You just want some code to start working, the following markup will allow interaction events in the +1 button:

 <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" > 

The following code will handle events:

 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); } 

The callback returns the +1 state of the button, the start / end of the interaction indicates the state of the user. You can see a demo of all the events here .

+9
source

Try reading their documentation, which is actually not bad. They provide access to the callback function. See section tag attributes .

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

+2
source

All Articles