Showing popup in the new Facebook JavaScript SDK

前端 未结 9 1549
遥遥无期
遥遥无期 2020-12-30 17:15

I used to have an href in my website. When users clicked on it, a multi-friend selector showed so they could invite their friends to my website. That was done u

9条回答
  •  执念已碎
    2020-12-30 17:36

    The following code works for me, but please note the following:

    • The width and height refer to the dialog-box itself, WITHOUT the "faded" thick blue border.
    • The width + height appear in the following code in 3 places.
    • The COLS and ROWS attribute match the size in the following example - 625x515 pixels.
    • Since IE sucks, I had to use jQuery with $.browser to force a POP-UP in IE.

    Hope this helps :)

    function fb_invite_friends() {
        FB.ui({method:'fbml.dialog', display:($.browser.msie ? 'popup' : 'dialog'), size:{width:625,height:515}, width:625, height:515, fbml:' '});
    }
    
    $(document).ready(function() {
    
        /* Facebook */
        window.fbAsyncInit = function() {
            FB.init({appId: fb_app_id, status: true, cookie: true, xfbml: true});
            if (facebook_canvas) {
                FB.Canvas.setAutoResize(4000); // Will resize the iFrame every 4000ms
            }
            FB.Event.subscribe('edge.create', function(response) {
                // The user clicked "LIKE", so we give him more coins!
                $.get(href_url, {action:'log_likes'});
            });
            // FBML Dialog size fix
            FB.UIServer.Methods["fbml.dialog"].size = {width:625, height:515};
        };
        (function() {
            var e = document.createElement('script'); e.async = true;
            e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
            document.getElementById('fb-root').appendChild(e);
        }());
    
    }
    

提交回复
热议问题