[英]W3C validation for Twitter widget
I use Twitter Widget
in my application [asp.net c#].我在我的应用程序 [asp.net c#] 中使用Twitter Widget
。 My code is:我的代码是:
StringBuilder strTwittsViewer = new StringBuilder();
strTwittsViewer.Append("</span><span class='cssClassFollowButton'><a href=\"https://twitter.com/Shree\" class=\"twitter-follow-button\" data-show-count=\"false\">Follow @Shree</a>");
strTwittsViewer.Append("<script type='text/javascript'>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=\"//platform.twitter.com/widgets.js\";fjs.parentNode.insertBefore(js,fjs);}}(document,\"script\",\"twitter-wjs\");</script></span></p>");
but my code unable to pass W3C validation .I got a error但是我的代码无法通过W3C 验证。我得到了一个错误there is no attribute "data-show-count" …witter-follow-button" data-show-count="false">Follow @shree</a><script typ…
I search and find this solution but unable to understand how to implement this solution with my code.Thanks.我搜索并找到了这个解决方案,但无法理解如何用我的代码实现这个解决方案。谢谢。
Because data attributes are part of the HTML 5 spec .因为数据属性是HTML 5 规范的一部分。 Use <!DOCTYPE html>
to specify the HTML 5 doctype使用<!DOCTYPE html>
指定 HTML 5 文档类型
OR要么
Put your link code into document.write so you'll have将您的链接代码放入 document.write 中,这样您就可以
strTwittsViewer.Append(@"<script language=""javascript"" type=""text/javascript"">");
strTwittsViewer.Append(@"//<![CDATA[");
strTwittsViewer.Append(@"document.write('<span class=""cssClassFollowButton""><a href=\""https://twitter.com/Shree\"" class=\""twitter-follow-button\"" data-show-count=\""false\"">Follow @Shree</a>"");");
strTwittsViewer.Append(@"//]]>");
strTwittsViewer.Append(@"</script>");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.