i have a Facebook app which has a button that brings up the Facebook requests dialog. When this button is clicked the first time the page loads, the request dialog pops up in the a new window, and this new window doesn't work half the time (freezes up and requires me to close all browser windows). but on the times where i does work and lets me close it, and i click my button again, it ope开发者_Go百科ns correcty, in a dialog with the shadow and everything.
My question is, how can arrange it to not open in a new window the first time click and possible close my app. Here is my code that runs the dialog:
//shows pop up window for inviting friends
function Invite()
{
FB.init(
{
appId:'<?echo $app_id;?>', cookie:true,
status:true, xfbml:true
});
FB.ui(
{
method: 'apprequests',
message: 'Insert Message Here'
});
}
and here is my button code if that matters:
`<button onclick="Invite();">Invite Friends!</button>`
i am using he Javascript SDK. I have searched for this, but go nothing.
In my console, when the dialog opens in a new window, it shows the error: Image corrupt or truncated:
You should call FB.init() function outside from Invite() function. FB need some time to load itself. Try to place FB.init() separate in top of your page (after body tag).
精彩评论