我希望添加鸣叫时,foo函数将起作用,但是仅当您单击打开模式窗口的按钮时,该函数才起作用。
window.twttr = (function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0],
t = window.twttr || {};
if (d.getElementById(id)) return;
js = d.createElement(s);
js.id = id;
js.src = "https://platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);
t._e = [];
t.ready = function (f) {
t._e.push(f);
};
return t;
}(document, "script", "twitter-wjs"));
function foo(intentEvent) {
console.log(intentEvent);
}
twttr.ready(function (twttr) {
twttr.widgets.createShareButton(
'/',
document.getElementById('my_id'),
{
text: 'Hello World'
}
);
twttr.events.bind('tweet', foo);
});