2
其他人不再在Safari中获得弹出窗口?FB.login popup不再适用于Safari mac吗?
下面是一些在Safari中无法使用的示例代码。它通过点击链接启动,因此弹出式窗口拦截器不应该阻止它。任何想法为什么它呢?
在线例子在这里:
http://users.telenet.be/prullen/fbtest.html
注意,这将无法通过预期的行为运行,因为它是在另一个域和具有不正确的应用程序ID。但这个例子唯一重要的是显示弹出窗口。
<script type="text/javascript">
var fbLoaded = false;
var doReLogin = true;
function createAccessToken(){
if (!fbLoaded) {
FB.init({
appId : 'xxx', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
}
fbLoaded = true;
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
getExtendedAccessToken(response.authResponse);
} else {
FB.login(function(response) {
if (response.status == 'connected') {
if (response.authResponse && response.authResponse.accessToken) {
getExtendedAccessToken(response.authResponse);
} else {
alert('You cancelled login or did not fully authorize.');
}
} else {
alert('To use you have to create an access token.');
}
}, {scope: 'read_stream'});
}
}, true);
}
function getExtendedAccessToken() {
}
</script>
<p style="text-align:center;"><a href="#" onclick="createAccessToken();return false;" class="connect">Connect With FaceBook</a></p>
你可以创建一个包含所有必需库的jsfiddle吗? – colllin
@collindo无法在jsfiddle上运行,因此将其放置在另一个域上。谢谢。 – Wesley