是否可以验证xmlns:fb(Facebook)属性? [英] Is it possible to validate the xmlns:fb (Facebook) attribute?

查看:121
本文介绍了是否可以验证xmlns:fb(Facebook)属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站上有一个Facebook Like按钮,因此也有 xmlns:fb 属性在< html> 标签:

I have a Facebook Like button on my site and as such also have the xmlns:fb attribute on the <html> tag:

<!DOCTYPE html>
<html lang="en" xmlns:fb="http://www.facebook.com/2008/fbml">

但是,当通过W3C验证器运行我的网站时,我收到以下错误:

However, when running my site through the W3C validator, I get these errors:


第2行第61列:属性xmlns:这里不允许fb。

Line 2, Column 61: Attribute xmlns:fb not allowed here.

第2行,列61:属性与本地名称xmlns:fb不可序列化为XML 1.0。

Line 2, Column 61: Attribute with the local name xmlns:fb is not serializable as XML 1.0.

行222,列72:属性fb:like:layout不可序列化为XML 1.0 。

Line 222, Column 72: Attribute fb:like:layout is not serializable as XML 1.0.

行222,列72:属性fb:like:此时不允许元素a上的布局。

Line 222, Column 72: Attribute fb:like:layout not allowed on element a at this point.

我的理解是,使用 xmlns:fb 属性将 fb 添加到文档命名空间,因此使用任何< fb:元素是有效的。那不是吗?这是HTML5问题吗?

It is my understanding that using the xmlns:fb attribute adds fb to the document namespace, so that using any <fb: element is valid. Is that not the case? Is it a HTML5 issue?

我也有与Twitter按钮类似的验证错误,是否可以修复这些?

I also have similar validation errors with the Twitter button, is it possible to fix those as well?


第223行,第53列:属性tw:via不可序列化为XML 1.0。

Line 223, Column 53: Attribute tw:via is not serializable as XML 1.0.

第223行第53列:属性tw:此时不允许在元素a上。

Line 223, Column 53: Attribute tw:via not allowed on element a at this point.


推荐答案

没有使用HTML5验证 xmlns:fb 的方法。

There is no way to validate xmlns:fb with HTML5.

但是,您可以使用新的 data -... -attributes,由Facebook添加并且是有效的HTML5,如此处所述

However, you can use the new data-...-attributes, which were added by Facebook and are valid HTML5, as described here.

这是一个如何在HTML5中使用此扩展的示例(假设所有代码都在body元素中):

This is an example of how you can use this extension in HTML5 (assume all code is in the body element):

<h3>Members</h3>
<embed data-fb="login-button" data-show-faces="true" />
<h3>Recent activity</h3>
<embed data-fb="activity" data-site="***" data-width="200" data-header="false"
 data-border_color="#fff" data-recommendations="false" />
<div id="fb-root"></div>
<!-- the JavaScript API -->
<script src="http://connect.facebook.net/en_US/all.js"></script>
<!-- the extention script from this article -->
<script src="/scripts/fb.js"></script>
<script>
 //<![CDATA[
 FB.init({apiKey: '***', appId: '***', status: true, cookie: true, fbml5: true});
 //]]>
</script>

这将是等效的XHTML代码:

This would be the equivalent XHTML code:

<h3>Members</h3>
<fb:login-button show-faces="true" />
<h3>Recent activity</h3>
<fb:activity site="***" width="200" header="false"
 border_color="#fff" recommendations="false" />
<div id="fb-root"></div>
<!-- the JavaScript API -->
<script src="http://connect.facebook.net/en_US/all.js"></script>
<!-- the extention script from this article -->
<script src="/scripts/fb.js"></script>
<script>
 //<![CDATA[
 FB.init({apiKey: '***', appId: '***', status: true, cookie: true, fbml5: true});
 //]]>
</script>

这篇关于是否可以验证xmlns:fb(Facebook)属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆