0

I need help with this, i need to be able to detect when the button is clicked. if anyone has a solution please provide one via jsfiddle or some other way.

Thank you.

<div class="g-ytsubscribe" data-channel="GoogleDevelopers" data-layout="default" data-count="default"></div>

document.getElementById("").onclick = function(){alert("Haha")};

JSFiddle

  • It's a duplicate question (the Google API replaces your div with an iframe), but just to make it clear as it is not the chosen answer: [use this one](http://stackoverflow.com/a/23231136/1913729) – blex Apr 24 '16 at 23:35
  • 1
    @Blex, this question is not a duplicate per say, while the subscribe button does live in a iframe, the Youtube API allows for callbacks when a user subscribes/unsubscribes. https://developers.google.com/youtube/youtube_subscribe_button – Patrick Evans Apr 24 '16 at 23:38
  • @PatrickEvans Ok, sorry. I've tested the documentation's code, it does not work for me, and the issue is visible [here](https://code.google.com/p/gdata-issues/issues/detail?id=5887). Most probable explanation mentionned: _"the event will not fire if the subscribing user has their subscriptions set to "private" in the YouTube privacy settings."_ I'll vote to reopen the question, but I guess that sentence does answer OP's question, so the "duplicate question" might be his best choice, even if it does not detect the difference between a "subscribe" click and an "unsubscribe" one. – blex Apr 24 '16 at 23:52

0 Answers0