使用 Facebook JS SDK 和 xhtml strict 时出现几个 xml 错误

发布于 2024-10-16 14:13:15 字数 1375 浏览 3 评论 0原文

我正在尝试为项目设置一些类似的按钮。这些按钮位于 Aino's Galleria 的 jquery 幻灯片中,让您“喜欢”每张不同的幻灯片。我正在使用严格的 xHTML 文档,在 Firefox(和 Firebug)中一切似乎都正常,但在 webkit 检查器中我得到这个:

   XML self-closing tag syntax used on <fb:like>. The tag will not be closed.
   [The HTML that caused this error was generated by a script.] XML self-closing tag syntax used on <fb:like>. The tag will not be closed.

我每张幻灯片都会收到其中一个错误,因此有 28 个错误。调查一下,发现有些似乎将 fb:like 括起来,如下所示:

<script type="text/javascript">
//<![CDATA[
document.write('<fb:like href="<?php echo "http://www.site/image-".$image_id ;?>" width="260" height="80" show_faces="false" />');
//]]>
</script>

上述内容在 Firefox 中仍然有效,但在 Safari 中无效。检查员说:

26 XFBML tags failed to render in 30000ms.

此外,对于与 Galleria Jquery 插件一起使用的 Facebook 之类按钮,我有一个自定义函数,它仅重新加载与实际幻灯片相关的 facebook 之类按钮,该按钮在加载幻灯片时会短暂出现:

[...]
extend: function(options) {
       // listen to when an image is shown
       this.bind(Galleria.IMAGE, function(e) {
            number = e.index + 1;
        tag = $('.galleria-info-description .info-box-'+number).find('.btn_fb');
    $(tag).each(function() {
            FB.XFBML.parse( this );
        });
    });
}

这件事越来越复杂,真不知道是谁造成的问题!希望有人可以提供帮助或提出正确的问题!

I'm trying to set up some like buttons to a project. These buttons live inside a jquery slideshow with Aino's Galleria and let you "Like" each different slide. I'm using an xHTML strict document and while in Firefox (and Firebug) everything seems ok, but in webkit inspector I get this:

   XML self-closing tag syntax used on <fb:like>. The tag will not be closed.
   [The HTML that caused this error was generated by a script.] XML self-closing tag syntax used on <fb:like>. The tag will not be closed.

I get one of these every slide, so there are 28 errors. Looking into it, found some seem to enclose the fb:like into something like this:

<script type="text/javascript">
//<![CDATA[
document.write('<fb:like href="<?php echo "http://www.site/image-".$image_id ;?>" width="260" height="80" show_faces="false" />');
//]]>
</script>

The above, still works in Firefox, but not in Safari. The inspector says:

26 XFBML tags failed to render in 30000ms.

Moreover, for the Facebook like buttons to work with the Galleria Jquery plugin, I have a custom function that reloads only the facebook like button concerning the actual slide which appears briefly upon loading the slide:

[...]
extend: function(options) {
       // listen to when an image is shown
       this.bind(Galleria.IMAGE, function(e) {
            number = e.index + 1;
        tag = $('.galleria-info-description .info-box-'+number).find('.btn_fb');
    $(tag).each(function() {
            FB.XFBML.parse( this );
        });
    });
}

This thing is getting more complex and really don't know who is causing the problem! Hope somebody can help or ask the right questions!

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

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

发布评论

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

评论(3

世界如花海般美丽 2024-10-23 14:13:15

将此属性添加到您的 标记中:

xmlns:fb="http://www.facebook.com/2008/fbml"

如果这不起作用,您可以尝试以 iFrame 形式生成按钮,而不是使用 XFBML 标记。

Add this attribute to your <html> tag:

xmlns:fb="http://www.facebook.com/2008/fbml"

If that doesn't work, you could try generating the buttons in iFrame form instead of using the XFBML tags.

栖迟 2024-10-23 14:13:15

您在此处尝试使用的代码是开放社交 DTD 的一部分。 XHTML Strict 无法解析此代码,它不是规范的一部分,因此无效。

查看 Facebook Open Social 文档
您将看到该文档必须使用非常不同的 DTD 进行标记。

The code that you are trying to use here is part of the Open Social DTD. XHTML Strict is not able to parse this code, it is not part of the spec and is therefore invalid.

Take a look at the documentation for Facebook Open Social
and you will see that the document must be marked up with a very different DTD.

小兔几 2024-10-23 14:13:15

尝试使用HTML5,它不像XHTML那么严格,尤其是XHTML严格。无论如何,XHTML 已经死了。

Try using HTML5 instead, it's not as strict as XHTML and especially XHTML strict. XHTML is dead anyway.

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