San*_*til 5 javascript safari popup facebook-javascript-sdk
我正在创建一个显示Facebook好友的应用程序.首先,用户需要点击登录按钮,然后在填写登录ID和密码后会出现一个简单的弹出屏幕,它会显示好友列表.
一切正常,可在Firefox,Chrome,IE上运行但不会在Safari和iPhone中打开弹出窗口.
有人建议我添加域名和频道名称channelUrl.我创建一个channel.html并添加引用,但它没有帮助我.
我搜索了很多,但没有找到帮助.
这是我的代码.
Custom.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();
});
});
Run Code Online (Sandbox Code Playgroud)
channel.html
<script src="//connect.facebook.net/en_US/all.js"></script>// i add this line in channel.html
Run Code Online (Sandbox Code Playgroud)
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;"/>
Run Code Online (Sandbox Code Playgroud)
好吧...在浪费了一整天的时间后我得到了答案。使用Javascript_Facebook Sdk,当您单击“登录”按钮时,它将打开弹出窗口。在 Safari 或 iPhone(我的)中,我启用了“阻止弹出窗口”选项。
因此我看不到 Facebook 登录窗口。您需要允许弹出窗口。
您可以通过单击允许弹出窗口
Safari-disable Block pop-up windows
Run Code Online (Sandbox Code Playgroud)
或者
safari-preference-then disable checkbox of pop-up window's
Run Code Online (Sandbox Code Playgroud)
或者您可以使用键盘快捷键:
shift-[command key]-K.
Run Code Online (Sandbox Code Playgroud)
干杯。
| 归档时间: |
|
| 查看次数: |
9704 次 |
| 最近记录: |