javascript Facebook 登录未在 Safari/iPhone 中打开

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12493198/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 16:19:40  来源:igfitidea点击:

Facebook Login not open in Safari/ iPhone

javascriptsafaripopupfacebook-javascript-sdk

提问by Sandip Armal Patil

I am creating one application which show Facebook friend. First, user need to click on login button then one simple popup screen will appear after filling login id and password it will show friend list.
Everything ok and run on Firefox, Chrome,IE but it will not open popup in Safari and iPhone.
someone suggest me add domain name and channel name in channelUrl. I create one channel.htmland add reference but it didn't help me.
I search lot's but didn't find helpful.

我正在创建一个显示 Facebook 好友的应用程序。首先,用户需要点击登录按钮,然后在填写登录ID和密码后会出现一个简单的弹出屏幕,它会显示好友列表。
一切正常,可在 Firefox、Chrome、IE 上运行,但不会在 Safari 和 iPhone 中打开弹出窗口。
有人建议我在channelUrl. 我创建了一个channel.html并添加了参考,但它没有帮助我。
我搜索了很多,但没有找到有用的。

Here is my code.
Custom.js

这是我的代码。
自定义.js

function getUser()
{
FB.init({
    appId      : '289403314507596', // App ID
    channelUrl : 'http://bc2-236-161.compute-1.amazonaws.com/html/channel.html', // Channel File
    status     : true, // check login status
    cookie     : true, // enable cookies to allow the server to access the session
    xfbml      : true  // parse XFBML
});

 (function(d){
 var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
 if (d.getElementById(id)) {return;}
 js = d.createElement('script'); js.id = id; js.async = true;
 js.src = "//connect.facebook.net/en_US/all.js";
 ref.parentNode.insertBefore(js, ref);
 }(document));

//check current user login status
FB.getLoginStatus(function(response) {
    if (response.status === 'connected') {
        window.location="facebook_friend.html"
        loadFriends();
    } else {
        //user is not connected.
        FB.login(function(response) {
            if (response.authResponse) {
                window.location="facebook_friend.html"
                loadFriends();
            } else {
                alert('User cancelled login or did not fully authorize.');
            }
        });
    }
 });
 }
//start from here
 $(document).ready(function(){
$('.load-button').click(function(){
    getUser();
});
});   

channel.html

频道.html

<script src="//connect.facebook.net/en_US/all.js"></script>// i add this line in channel.html

refer_friend.html
I add reference of custom.jsin this file

refer_friend.html
custom.js在这个文件中添加了引用

 <div id="fb-root"></div>
   <script src="http://connect.facebook.net/en_US/all.js"></script>
   <img src="includes/fb-btn1.png" class="load-button" style="
    width: 290px;
    Height: 40px;
    margin-top: 5px;"/>

采纳答案by Sandip Armal Patil

Ok... After wasting my full day i got a answer. Using Javascript_Facebook Sdk, when you click on Login button, it will open popup window. And in Safari or iPhone(mine), i enable Block-popup option.
Therefore i am not able to see Facebook login window. you need to allow pop-up window.
You can allow pop-up by clicking on

好的...在浪费了我一整天的时间后,我得到了答案。使用Javascript_Facebook Sdk,当您单击登录按钮时,它将打开弹出窗口。在 Safari 或 iPhone(我的)中,我启用了 Block-popup 选项。
因此我无法看到 Facebook 登录窗口。您需要允许弹出窗口。
您可以通过单击允许弹出

Safari-disable Block pop-up windows  

or

或者

 safari-preference-then disable checkbox of pop-up window's    

or You can use a keyboard shortcut:

或者您可以使用键盘快捷键:

shift-[command key]-K.

cheers.

干杯。