Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google+ share and onendinteraction - no confirm

I'm setting up a google+ share button, and want to know when someone has shared the link so that I can perform an action. You can register a callback on the share button using the onendinteraction attribute, and the documentation states that this will be called whenever the share box is closed and whenever the share is completed.

My function is being called when the window is closed, but not when the link is actually shared:

function redirectGooglePlus(jsonParam) {
    alert(jsonParam.type);
}
<div class="g-plus" data-action="share" data-annotation="vertical-bubble" data-height="60"
                 data-href="http://mywebsite.com" data-onendinteraction="redirectGooglePlus"></div>

My function redirectGooglePlus is only ever called when the hover type, and never confirm (which is the one that is supposed to signify the share has been completed.

Does anyone know why the function isn't called with confirm?

FYI the google share documentation is here: https://developers.google.com/+/web/share/

like image 569
John Farrelly Avatar asked Nov 12 '22 23:11

John Farrelly


1 Answers

So this appears to be a bug with the current implementation of the google+ share button:

https://code.google.com/p/google-plus-platform/issues/detail?id=396

The (hideous) workaround I've used for now is to look for 2 hover events for the onendinteraction. If the events come in quick succession (less than 1 second), then it's likely they've shared the item.

like image 52
John Farrelly Avatar answered Nov 14 '22 23:11

John Farrelly