Question

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);
});
Was it helpful?

Solution

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

OTHER TIPS

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

https://developers.facebook.com/docs/reference/dialogs/send/ This has an example of bringing up the dialog with javascript

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top