在我发布到Facebook之后如何关闭弹出窗口? [英] How do I close the popup after I post to facebook?

查看:184
本文介绍了在我发布到Facebook之后如何关闭弹出窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的博客上,我们有一个链接,用户可以将文章发布到他们的时间表。弹出窗口打开,用户发布到Facebook,然后弹出窗口停留在那里,并重定向到www.oursite.com。当用户完成发布或点击取消按钮时,我们如何关闭弹出窗口?根据这个问题不能做,但霍芬顿的帖子已经弄清楚了,但看着他们的代码,我们无法想像出来。
举例来说, facebook share 按钮这里将打开一个弹出窗口,然后关闭,当您发布文章或取消。

On our blog we have a link where users can post our articles to their timeline. A popup opens up and the user posts to facebook, then the popup stays there and redirects to "www.oursite.com". How do we instead close the popup when the user either finishes posting or clicks on the cancel button? According to this so question it can't be done but Huffington post has figured it out but looking at their code we can't figure it out. As an example, the facebook share button here will open up a popup and then close when you either post the article or cancel.

这是我们所拥有的:

FB.init({appId: "90210", status: true, cookie: true});

      function postToFeed() {

        // calling the API ...
        var obj = {
          method: 'feed',
          redirect_uri: 'http://www.oursite.com/',
          link: 'http://www.oursite.com/',
          picture: 'http://www.oursite.com/png.png',
          name: 'Some title',
          caption: '',
          description: ''
        };

        function callback(response){
           window.close(); // doesn't do anything
          //document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
        }

        FB.ui(obj, callback);
      }

我们尝试添加window.close();在回调(和self.close();),尝试离开redirect_uri空白(并尝试将redirect_uri完全退出,但它是必需的)。

We've tried adding window.close(); in the callback (and also self.close();), tried leaving redirect_uri blank (and tried leaving redirect_uri out altogether, but it's required).

推荐答案

重定向到 http://oursite.com/#close_window 。然后在您的网站的主页上添加如下内容:

Redirect to http://oursite.com/#close_window. Then on your site's homepage, include something like this:

if(window.location.hash =='#close_window')window.close );

这篇关于在我发布到Facebook之后如何关闭弹出窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆