gpt4 book ai didi

jquery - 检测 FB 嵌入后 iframe 上的点击

转载 作者:行者123 更新时间:2023-12-01 04:04:32 25 4
gpt4 key购买 nike

尝试使用 iframeTracker-jquery 库检测 FB 嵌入帖子的点击。FB有JS SDK,可以帮助在第三方网站嵌入帖子。

此嵌入代码:

<div class="fb-post" 
data-href="https://www.facebook.com/permalink.php?story_fbid=811932475541152&id=361136907287380"
data-width="350"></div>

FB SDK 将其转换为 iframe:

<div fb-post>
<span>
<iframe>
....
</iframe>
</span>
</div>

此 iframe 跟踪器调用不起作用:

$(document).ready(function($){
$('.fb-post > span > iframe').iframeTracker({
blurCallback: function(){
console.log('Horray')
}
});
});

你能帮我理解为什么会发生这种情况吗?如何检测 FB post iframe 中的点击?

最佳答案

[from comments] the problem with FB embedded post is that jquery iframe selector don't find them on document ready. How come?

因为只有<div class="fb-post" …></div> 在加载时出现在您的页面中。 SDK异步加载,初始化后才插入iframe。

如果您想在 SDK 完成将这些元素渲染到社交插件中时触发某些操作,那么您可以订阅 xfbml.render事件;这是

“[f]ired when FB.XFBML.parse() completes. This indicates that all of the social plugins on the page have been loaded.”

参见https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/v2.4了解详情。

关于jquery - 检测 FB 嵌入后 iframe 上的点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31668945/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com