我添加了以下代码,它在Web上工作得很好,但在移动设备上却不是,单击事件似乎不会触发。
var FacebookShare = function() {
this.method = 'feed';
this.name = 'A Name';
this.hashtag = '#YourHashtag';
};
$('#facebook-share').click((event) => {
let options = new FacebookShare();
options.quote = $(event.currentTarget.parentElement).find('h5').html()
facebookshare(event, options)
});
function facebookshare(event, options) {
event.preventDefault()
if(typeof(mobileApp) !== 'undefined'){
options.display = "touch"; //also tried iframe, popup
FB.ui(options,
function() {
console.log('shared');
})
}
} 发布于 2021-11-19 16:07:21
通过使用引号重载以下查询字符串,我找到了解决此问题的方法-这是您想要引用的文本和一个图像(url)。唯一的缺点是我不能给我的帖子添加一个标签,但总而言之,它是有效的!
var u = encodeURI(options.picture);
var q = encodeURI(options.quote);
window.location.href = "https://www.facebook.com/sharer/sharer.php?u=" + u + `"e=${q}&display=popup&ref=plugin&src=like&kid_directed_site=0&app_id=YOUR_APP_ID`https://stackoverflow.com/questions/70009178
复制相似问题