使用 jQuery 移动除法时 Facebook 代码重复
我试图根据用户窗口的宽度使用 jQuery 移动网站的一个部分。我已经成功地完成了这方面的工作,但是我要移动的分区包含一些 Facebook 代码,当 jQuery 移动它时,它会变得重复并出现两次(导致两个 iFrame)。
我的 HTML 头部有这一行。
<script type="text/javascript" src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US"></script>
然后,这是当我移动 div 时重复的行(我已用 X 替换了我的 ID):
<script type="text/javascript">FB.init("XXXXXXXXX");</script>
<fb:fan profile_id="XXXXXXXXXX" stream="0" connections="4" logobar="0" width="240" height="130" css="http://www.indiecity.com/account/css/facebook-like.css?6"></fb:fan>
我使用remove() 和append() 来移动分区,因为它需要出现在不同的容器中(div )。我也尝试过将 FB.init 放在 html 的头部,但这不起作用。什么也没出现。
有什么想法吗?
干杯。
I'm attempting to move a division of the website with jQuery depending on the width of the user's window. I've managed to accomplish this aspect, however the division I'm moving contains some Facebook code, and when jQuery moves it, it becomes duplicated and appears twice (resulting in two iFrames).
I have this line in my the HTML head.
<script type="text/javascript" src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US"></script>
Then this is the line(s) that duplicates when I move the div (I have replaced my IDs with Xs):
<script type="text/javascript">FB.init("XXXXXXXXX");</script>
<fb:fan profile_id="XXXXXXXXXX" stream="0" connections="4" logobar="0" width="240" height="130" css="http://www.indiecity.com/account/css/facebook-like.css?6"></fb:fan>
I'm using remove() and append() to move the division because it needs to appear in different containers (divs). I have tried putting the FB.init in the head of the html too, but that didn't work. nothing showed up.
Any ideas?
Cheers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这种情况下似乎发生的是,当代码被复制到页面的新部分时,init() 函数被再次调用。这意味着两个连接正在进行中。
因此,风扇盒本身已加倍。
What appeared to be happening in this case was that when the code was copied to a new part of the page the init() function was called again. Which then meant that two connections where in process.
Therefore the fan box double populated itself.