按下按钮后,我有以下脚本激活facebook对话框屏幕。虽然有一些用户操作,但弹出窗口仍然被阻止。我搜索了很多关于这个问题,但我无法弄清楚如何解决这个问题:(我希望有人可以帮助我!
脚本由以下按钮触发:
onClick="fb_callout();
脚本:
<div id="facebook-root"></div>
<script>
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : '', // App ID from the App Dashboard
channelUrl : '', // Channel File for x-domain communication
status : true, // check the login status upon init?
cookie : true, // set sessions cookies to allow your server to access the session?
xfbml : true // parse XFBML tags on this page?
});
// Additional initialization code such as adding Event Listeners goes here
FB.ui(
{
method: 'feed',
//display: 'iframe',
name: '',
link: '',
picture: '',
caption: '',
description: ''
},
function(response) {
if (response && response.post_id) {
window.location.href = '';
} else {
alert('');
}
}
);
};
// Load the SDK Asynchronously
function fb_callout() {
(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/nl_NL/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
}
</script>
根据你的(CBroe)指令,我改变了一下脚本。而现在它似乎工作! :) 弹出窗口出现没有问题。
结果:
<div id="facebook-root"></div>
<script>
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : '', // App ID from the App Dashboard
status : true, // check the login status upon init?
cookie : true, // set sessions cookies to allow your server to access the session?
xfbml : true // parse XFBML tags on this page?
});
// Additional initialization code such as adding Event Listeners goes here
};
// Load the SDK Asynchronously
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function fb_callout()
{
FB.ui(
{
method: 'feed',
name: '', // name of the product or content you want to share
link: '', // link back to the product or content you are sharing
picture: '', // path to an image you would like to share with this content
caption: '', // caption
description: '' // description of your product or content
},
function(response) {
if (response && response.post_id) {
window.location.href = '';
} else {
alert('Post was not published.');
}
}
);
}
</script>