将click()事件附加到Google加号按钮吗? [英] Attach a click() event to the google plus button?
本文介绍了将click()事件附加到Google加号按钮吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当用户单击"g +"按钮时,我想在页面上添加警报消息.我怎样才能做到这一点?
这是代码:
I'd like to add a alert message on the page when a user clicks 'g+' button. how can i achieve this ?
here is 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>
推荐答案
只是在您需要一些代码入门的情况下,以下标记将在+1按钮中启用交互事件:
Just incase you want some code to get you started, the following markup will enable the interaction events in a +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"
>
以下代码将处理事件:
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状态,开始/结束交互指示用户状态.您可以在此处看到所有事件的演示.
The callback will return the +1 state of the button, start/end interaction indicates the user state. You can see a demo of all the events here.
这篇关于将click()事件附加到Google加号按钮吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文