我尝试使用以下函数构建新按钮:
function simulateClick(x, y) {
jQuery(document.elementFromPoint(x, y)).click();
};
我的完整代码是:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script>
window.fbAsyncInit = function () {
FB.init({
appId: 'MY_APP_ID',
status: false,
cookie: false,
xfbml: true
});
//Additional
FB.Event.subscribe('edge.create',
function (response) {
alert('LIKED: ' + response);
}
);
};
// Asynchronously
(function (d) {
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) { return; }
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
} (document));
function simulateClick(x, y) {
jQuery(document.elementFromPoint(x, y)).click();
};
</script>
<fb:like href="https://www.facebook.com/" send="false" layout="button_count" width="200" show_faces="false"></fb:like>
<a href="javascript:simulateClick(20, 10);">Click to Like</a>
但它不起作用,我不知道为什么? 请帮帮我!