跟踪Google Plus按钮上的click()事件?

时间:2013-12-18 09:17:07

标签: javascript asp.net-mvc

我正在尝试捕获Google+按钮点击,但未成功执行此操作。

我在我的实现中使用了“onstartinteraction”,不幸的是,即使用户将鼠标悬停在G + Button上,此方法也会被触发。

我尝试使用“数据回调”,但是,只有在用户点击G +按钮&登录弹出的Google+登录窗口。 我的要求是在用户点击G +按钮时捕获点击。

非常感谢任何帮助。感谢。

这是.cshtml:

<!DOCTYPE html>
<html>
<head>
<title>Google Plus Click</title>
@Scripts.Render("~/scripts/jquery-1.9.1.js")
@Scripts.Render("https://apis.google.com/js/plusone.js")
<meta name="view" content="width=device-width" />
</head>
<body>
<table cellspacing="0" border="0" cellpadding="0">
<tbody>
<tr>
<td>
<div class="g-plusone" data-size="medium" data-annotation="none" data-onstartinteraction="plusClick">
</div>
</td>
</tr>
</tbody>
</table>
</body>
</html>
<script type="text/javascript" language="javascript">
function plusClick(data) {
alert('G PlusOne Button Clicked');
}
</script>

1 个答案:

答案 0 :(得分:0)

<div class="g-plusone" data-size="medium" data-annotation="none" data-onstartinteraction="plusClick" onClick="plusClick.call(this,event)">

使用onClick,你可以激活你的功能。 NB。函数 plusClick plusClick.call(this,event)范围内的this是您点击的按钮,而您的data就是该事件。