问题描述
更新-编辑
我对共享对话的想法非常陌生,我想将此想法整合到我的网站中。
我有一个反应计时器游戏,可以在模式弹出窗口中以秒为单位显示用户的反应时间。我很想分享用户访问Facebook的反应时间。上面会有一些文字,例如:
[name]正在玩“反应时间”游戏并得分[var = reaction_time]。
共享按钮将在模式页脚上,供用户单击。
function share_result() {
let bestTime = document.getElementById("time").value;
FB.ui({
method: 'Feed',link: 'https://mysite.site/',quote: 'I scored ' + bestTime
},function(response){});
}
我可以调用弹出式窗口并获得“我得分”,但变量未定义。
也许我说错了吗?
关于缺少什么的任何线索吗?
解决方法
*已解决
function share_result() {
FB.ui({
method: 'feed',link: 'https://mysite.site',quote: 'I scored ' + window.time.toFixed(3) + ' s in the Reaction Time game at my site!'
},function(response) {
if (response && !response.error_message) {
alert('Posting completed.');
} else {
alert('Error while posting.');
}
});
}
我遇到的问题不是共享全局值。