FB Like 框仅显示在一页上

发布于 2024-12-01 18:05:17 字数 1116 浏览 1 评论 0原文

我有以下代码来显示文件中的 FB Like 框称为notify.html。

<div id="fb-root" class="fb_like"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<fb:like-box href="http://www.facebook.com/platform" width="270" height="250" show_faces="true" border_color="black" stream="true" header="true">
</fb:like-box>                              

该文件包含在我的所有其他页面中,以便 notification.html 中的所有内容都显示在所有页面的侧栏中。

然而,类似FB的框只出现在一个页面上,而这恰好是我也有FB注册表的页面。

为什么其他页面不显示?

类似框显示的一页上的FB注册码是

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
   FB.init({
      appId:'0000000000000', cookie:true,
      status:true, xfbml:true
   });
</script>
<fb:registration
  fields="[{'name':'name'},{'name':'emailEdu','description':'Your .edu Email','type':'text'},{'name':'captcha'}]"
  redirect-uri="http://myurlhere.com">
</fb:registration>

I have the following code to display the FB Like box in a file called notify.html.

<div id="fb-root" class="fb_like"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<fb:like-box href="http://www.facebook.com/platform" width="270" height="250" show_faces="true" border_color="black" stream="true" header="true">
</fb:like-box>                              

This file is included in all my other pages such that everything in notify.html shows up in a sidebar for all pages.

However, the FB like box only shows up on one page,, and that happens to be the page where I also have the FB registration form.

Why does it not show up in other pages?

The FB registration code on the one page the like box shows on is

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
   FB.init({
      appId:'0000000000000', cookie:true,
      status:true, xfbml:true
   });
</script>
<fb:registration
  fields="[{'name':'name'},{'name':'emailEdu','description':'Your .edu Email','type':'text'},{'name':'captcha'}]"
  redirect-uri="http://myurlhere.com">
</fb:registration>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

盗心人 2024-12-08 18:05:17

您需要在要使用 api 的每个页面上使用一次 FB.init 方法。如果您只有第一个示例中的代码而没有其他代码,则它不起作用,因为您尚未初始化 FB 对象。注册码上有 FB init,这就是它突然开始工作的原因。

You need the FB.init method once on every page you want to use the api with. If you only have the code from that first example and nothing else, its not working because you haven't initialised the FB object. On the registration code you have the FB init, which is why it suddenly starts working.

新雨望断虹 2024-12-08 18:05:17

看起来你并没有完全复制 FB 代码。从您引用的页面上的代码生成器中,您应该包含以下内容:

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<fb:like-box href="http://www.facebook.com/platform" width="292" 
show_faces="true" border_color="" stream="true" header="true"></fb:like-box>

-- 但您的脚本标记缺少 #xfbml 内容

另外使用 firebug 或类似的工具来查看是否收到任何 JS 错误。另请检查您是否没有双重加载 FB 库

已添加 我认为问题是您的 xffbml 标签未在其他页面上进行解析。希望修复脚本包含标签可以修复它......

Doesn't look like you're exactly copying the FB code. From their code generator on the page you referenced, you should be including the following:

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<fb:like-box href="http://www.facebook.com/platform" width="292" 
show_faces="true" border_color="" stream="true" header="true"></fb:like-box>

-- but your script tag is missing the #xfbml stuff

Also use firebug or similar to see if you are getting any JS errors. Also check that you're not double loading the FB libs

Added I think the problem is that your xffbml tags are not being parsed on the other pages. Hopefully fixing the script include tag will fix it...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文