English 中文(简体)
如何关闭与FB.ui(FB.ui)()开门的一张面纱?
原标题:How to close a facebook SDK dialog opened with FB.ui()?

我成功地展示了一位应邀的朋友方言(以下编码)。 当用户点击微镜时,iframe/dialog显示新页面。 然而,从这一点来看,我无法找到一种办法,来关闭iframe/dialog。 FB.ui don t 回去任何物体,似乎有Javascript SDK方法,而与OMM的 trav和操纵将陷入任何FB代码的变化。

任何想法?

function popupInviteForm(actionUrl) {
    var fbmlString =  <fb:fbml>  +
                  <fb:request-form type="POST" content="Play against me in game?" action="  + actionUrl +  " method="post" >  +
                      <fb:multi-friend-selector target="_self" exclude_ids="" max="20" cols="4" rows="3" showborder="false" actiontext="Invite friends!" />  +
                  </fb:request-form>  +
               </fb:fbml> ;

    FB.ui({
        method:  fbml.dialog ,
        fbml: fbmlString,
        display:  dialog ,
        size: {width:640,height:480}, width:640, height:480
    });

    $(".FB_UI_Dialog").css( width , $(window).width()*0.8);
}

(说明:我在facebook Forum上刊登了同样的问题,但没有答复。 如果对两者都有一个答案,我将更新这两份文件。

The Javascript Code was amended from apinack overflow answer

问题回答

I have same trouble. Second day looking for a solution. And just found one way: for closing active FB dialog you should perform followed code in parent window where FB JS is available and where FB.ui was called:

FB.Dialog.remove(FB.Dialog._active);

因此,如果你想要邀请的方言汽车关闭,不向任何其他页子转移,则采取这些步骤:

1) Set target attr of and as "_self":

目标=“自我”

2) create some callback url/page on your site, for example https://mysite/close_dialog.html

3) 采取 action行动:

行动=“http://mysite/close_dialog.html”

4) 在你本人的近亲中,遵循了联合材料:

    <script type="text/javascript">
        if (document.location.protocol ==  https: ) {
            document.location =  http://mysite/close_dialog.html ;
        } else {
            top.window.FB.Dialog.remove(top.window.FB.Dialog._active);
        };
    </script>

<><>UPDATE:

5) There is one issue else in this way: FB iframe loaded by https, but if request-form action attr uses http - user will get browser warning. But if request-form action has https - iframe js cant access to parent loaded by http . So, its the reason why you should use action by https

希望这一帮助

If you has better solution or you can improve this way - please let all know this, Thanks for any comments

这不是工作(至少对我而言)。

我所说的只是“javascript 窗户”,而不是上层:window.FB.Dialog.remove(top.window.FB.Dialog._active);而且它运作良好。

<script type="text/javascript">
    if (document.location.protocol ==  https: ) {
        document.location =  http://mysite/close_dialog.html ;
    } else {
        //alert( some message );
        window.close();
    };
</script>

FB.ui提供了在FB.ui完成后将执行的备用功能的选择。

FB.ui(
  {
    method:  .......... ,
    ..................
  },
  function(response) {
    //write your code here
  }
);

这是否有助于解决你的问题?

i 发现Igor Reshetnikov的回答的确奏效,但只有我确信能够宣布这两页——打开方言和关闭方言——作为使用文件同一领域的一部分。 领域。 因此,在两页的文字标签顶端,你必须添加这一条线。

document.domain =  mysite.com ;

显然,用你历来的领域取代我的现场。

这结束了所有方言,但可能由于内部变量<代码>_loadedNodes 而不能使用未来释放。

if (FB && FB.UIServer && FB.UIServer._loadedNodes) {
  var nodes = FB.UIServer._loadedNodes;
  if (nodes) {
    for (var item in nodes) {
      if (nodes[item].type && nodes[item].node && nodes[item].node.close &&
 nodes[item].type === "popup") {
        nodes[item].node.close();
      }
    }
  }
}

FWIW,我的浏览器的隐私假想阻止FB关闭方言。 我刚刚放弃了隐私假肢和方言。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签