Facebook invite friends plugin doesn't work after the first time

After I integrate the Facebook Invite Friends plug-in, the first time it’s loaded in any browser, it works fine, but when I try it second time (after a refresh or something) it just doesn’t open anymore. I keep clicking but it just doesn’t open.

This is the code:

function showPopup(pageURL, title, w, h) {
    var left = (screen.width / 2) - (w / 2);
    var top = (screen.height / 2) - (h / 2);
    var targetWin = window.open(pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
}

window.fbAsyncInit = function () {
    FB.init({
        //   appId      : 'my app id', // App ID
        //  channelURL : '//WWW.mydomain.COM/domainfolder/channel.php', // Channel File
        status: true,
        // check login status
        cookie: true,
        // enable cookies to allow the server to access the session
        oauth: true,
        // enable OAuth 2.0
        xfbml: true // parse XFBML
    });
    // Additional initialization code here
};

// Load the SDK asynchronously
(function (d) {
    var js, id = 'facebook-jssdk';
    if (d.getElementById(id)) {
        return;
    }
    js = d.createElement('script');
    js.id = id;
    js.async = true;
    js.src = "//connect.facebook.net/en_US/all.js";
    d.getElementsByTagName('head')[0].appendChild(js);
}(document));
//Replace the ALL_CAPS variables with your own values

function invite() {
    FB.getLoginStatus(function (response) {
        if (response.authResponse) {
            // logged in and connected user, someone you know
            FB.ui({
                method: 'fbml.dialog',
                width: '750px',
                fbml: '<fb:request-form target="_self" method="post" invite="true" type="Invite" content="Hey! Come join me on this site! Finally it\'s opened for us! <fb:req-choice url=\'http://www.mysite.com/site/index.php\' label=\'Accept\' />" <fb:multi-friend-selector showborder="false" actiontext="Invite friends" email_invite="true" import_external_friends="true" /> </fb:request-form>'
            });
        } else {
            // no user session available, someone you dont know
            FB.login();
        }
    });
}
function loaded() {
    document.getElementById('FBico').src = 'img/OtherServices/fb.png';
}

It’s in the head tag. It works perfectly the first time after clearing the history. Same happened in Internet Explorer 9, Firefox 8, Chrome and iPad iOS 5.

The all.js file from Facebook may get cached somewhere and not loading again. There is one little file with only /html/body/ above code /body//html/ which works all the time perfectly.

How can I prevent caching the all.js file from Facebook?

Answers


ok so i finally figured it out. the invite() function was being called when an image (facebook icon) was clicked. so the browsers were thinking that its an ad and 2nd time the invite() function was not being called. so after i replaced the tag with a button everything worked fine and facebook invite window opens up in all browsers without any problem.

btw, why my question got thumbs down? no one could answer the question? meh...


Need Your Help

Objective-C - Optimizing this singleton pattern?

iphone objective-c ios memory-management singleton

I've found that singleton pattern on the net. It seems to me it has many things that can be optimized.

Display a button to store data in database in an Android ListView

android web-services listview button

I have a simple Android ListView code that displays a list of names that is returned from the web service I have created. I need to add three buttons at the end of the List because:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.