开发者

Facebook LIKE button and W3C Validation Fails

http://developers.facebook.com/docs/reference/plugins/like

To include the popular a [Like] button from facebook, I must use the following code :

<iframe src="http://www.facebook.com/plugins/like.php?href=www.MyDomain.com&amp;layout=standard&amp;show_faces=false&amp;width=225&amp;action=like&amp;font=lucida+grande&amp;colorscheme=dark&amp;height=80" scrolling="no" frameborder="0" style="border:none;开发者_开发百科 overflow:hidden; width:250px; height:80px;" allowTransparency="true"></iframe>

My website no longer validate on W3C because of the allowTransparency attribute :

Line 313, Column 342: there is no attribute "allowTransparency"
… overflow:hidden; width:250px; height:80px;" allowTransparency="true"></iframe>

Is there a way around? I cannot use the XFBML version. This is pretty bad..

Marketing et Conception Web Sherbrooke


Have you tried omitting this attribute? It should not be required. The standards to not even mention it.


Ok, after going over literally hundreds of these posts, I finally found a quick and easy way to get a valid page with a Like button (or any other facebook widget) on it.

Just a fewlines of code really, take a look at http://www.liormark.com/develop/development-articles/facebook-fbml-w3c-validation-solved


The following code should fix the validation issue:

<script language="javascript" type="text/javascript">
//<![CDATA[
document.write('<fb:like send="true" width="600" show_faces="true"></fb:like>');
//]]>
</script>


If I remember correctly, allowtransparency is an attribute that Microsoft made up. So use a different code with Internet Explorer family to make it work and different code for other browsers to validate?

Although it's not something you should worry about, it's a good thing to follow the standards, but if your site doesn't validate because of things like that, it's not the end of the world.


Here is the best code:

Enjoy....:)

<div id="fb-root"></div>
    <script type="text/javascript" language="javascript">
    //<![CDATA[
    (function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
    fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
    //]]>
    </script>
    <script type="text/javascript" language="javascript">
    // <![CDATA[
    document.write('<fb:like href="URL" send="false" width="450" show_faces="false"></fb:like>');
    // ]]>
    </script>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜