让 Facebook“发送”按钮默认打开对话框
我想在我的网站上使用 Facebook“发送”按钮(如下所述:http ://developers.facebook.com/docs/reference/plugins/send)。
默认情况下,发送按钮在页面上显示为小按钮。当用户单击“发送”按钮时,它会打开一个更大的对话框。
我希望在页面加载时自动打开更大的对话框,就像用户单击“发送”按钮一样。
我并没有要求任何恶意。我只希望打开该对话框,因为这将位于我网站的“共享”页面上,并且打开的对话框看起来比小发送按钮要好得多。我不打算进行伪造的“发送”或任何其他垃圾邮件。
我尝试使用 jquery 这个简单的位,但它不起作用......
function expose() {
$(".fb_button").click();
}
$(document).ready(function() {
setTimeout(expose, 1000);
});
I'd like to use a Facebook "Send" button on my site (as described here: http://developers.facebook.com/docs/reference/plugins/send).
By default, the send button appears on the page as a small button. When the user clicks the Send button, it opens up into a much larger dialog box.
What I'd like is for that much larger dialog box to open automatically when the page loads, as if the user had clicked the Send button.
I'm not asking for anything malicious. I just want the dialog to be open since this will be on my site's "sharing" page, and the open dialog would look a lot better than the little Send button. I'm not planning on doing falsified "sends" or anything else spammy.
I tried this simplistic bit using jquery, but it doesn't work...
function expose() {
$(".fb_button").click();
}
$(document).ready(function() {
setTimeout(expose, 1000);
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
FB 社交插件不是“封装”在 iframe 内吗?如果是这种情况,您将无法将事件绑定到按钮。即使它不在 iframe 中,我认为 Facebook 也会试图阻止你“强制”自动点击,即使你的意图是好的
Aren't FB social plugins "encapsulated" inside an iframe? if that's the case you won't be able to bind an event to the button. And even if it's not in an iframe, I think Facebook will try to stop you from "forcing" an automated clicks even if your intentions are good
我在您的代码中看到的第一个问题是您将按钮称为 .fb_button,而我从您发布的 Facebook 开发人员链接中获得的代码是 .fb-send。考虑到您自己已经更改了这一点,问题在于从 setTimeout 调用该函数。它必须采用
希望有效的格式
The first issue I see with your code is that you're referring to the button as .fb_button, while the code I'm getting from the Facebook developers link you posted is .fb-send. Considering that you have changed that yourself, the issue is in calling the function from setTimeout. It has to be in the format
Hope that works
https://developers.facebook.com/docs/reference/dialogs/send/
这是一个使用 javascript 调出对话框的示例
https://developers.facebook.com/docs/reference/dialogs/send/
This has an example of bringing up the dialog with javascript