FB.ui弹出窗口没有关闭 [英] FB.ui popup window doesn't close

查看:70
本文介绍了FB.ui弹出窗口没有关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

初始化代码:

            FB.init({
                appId: '123456789012345', 
                channelUrl: 'http://localhost/Some/Url/FacebookChannel',
                status: true, 
                cookie: true, 
                oauth: true, 
                xfbml: true  
            });

通过onclick调用以下代码:

The following code is called with an onclick:

    FB.ui({
            method: 'feed',
            name: settings.facebookShareName,
            link: settings.facebookLinkUrl,
            caption: settings.facebookShareCaption,
            description: settings.facebookShareDescription,
            message: message,
            display: 'popup'
    });

此代码在FF和Chrome中运行良好,并且大多数在IE8中运行.显示弹出窗口,用户可以将其张贴到墙上,但是提交后,该窗口不会关闭.它变成白色,没有任何进一步的交互,但是必须由用户手动关闭.

This code works fine in FF and Chrome, and mostly works in IE8. The popup is shown and the user can post to their wall, but after submitting, the window doesn't close. It turns white with no further interaction, but must manually be closed by the user.

为什么IE中的窗口不会自动关闭,和/或是否有任何变通办法来强制弹出窗口关闭?

Why doesn't the window auto-close in IE, and/or are there any workarounds to force the popup to close?

此问题可能与未解决的错误有关.

This issue may be related to this outstanding bug.

推荐答案

我遇到了同样的问题,但从未能够从Facebook获得有关回调函数的响应.我在console.log中看不到任何内容,也没有在函数中插入任何警报.

I have the same problem and have never been able to get a response from Facebook for the callback function. I don't see anything in console.log or any alerts I insert in the function.

我的解决方案是在FB.ui的redirect_uri中放置一个URL,该URL转到带有self.close(或window.close)的HTML页面. FB.ui弹出窗口在用户输入后重定向到那里,并立即关闭.请记住,要更改FB应用程序的网站URL"设置,使其与文件所在的域相匹配.

My solution was to put a URL in FB.ui's redirect_uri that goes to an HTML page with self.close (or window.close). The FB.ui popup redirects there after the user's input and immediately closes. Remember to change your FB app's Site URL setting so it matches the domain the file resides on.

这是我的代码,与我的表单的提交操作有关.函数(响应)回调仍然存在,但未使用.如果有人看到语法错误,请对此发表评论.

Here's my code, tied to my form's submit action. The function(response) callback is still there but not used. If anyone sees a syntax error please comment on it.

    FB.ui ({
        method: 'feed',
        name: '',
        link: '',
        picture: '',
        caption: '',
        description: '',
        actions: {name:'',link:''},
        redirect_uri: 'http://.../self.close.html'
        },
        function(response) {
            console.log(response);
            if (response && response.post_id) {
                alert('yes');
                self.close();
            } else {
                alert('else yes');
            }
        });

self.close.html中的代码行:

The line of code in self.close.html:

<script type="text/javascript">self.close();</script>

这篇关于FB.ui弹出窗口没有关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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