让 Facebook“发送”按钮默认打开对话框

发布于 2024-12-10 10:54:07 字数 573 浏览 0 评论 0原文

我想在我的网站上使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

权谋诡计 2024-12-17 10:54:07

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

轮廓§ 2024-12-17 10:54:07

我在您的代码中看到的第一个问题是您将按钮称为 .fb_button,而我从您发布的 Facebook 开发人员链接中获得的代码是 .fb-send。考虑到您自己已经更改了这一点,问题在于从 setTimeout 调用该函数。它必须采用

        setTimeout("expose()", 1000);

希望有效的格式

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

        setTimeout("expose()", 1000);

Hope that works

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文