2012-04-09 40 views
1

我在我的應用程序[asp.net c#]中使用Twitter Widget。 我的代碼是:
W3C驗證Twitter部件

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>"); 

,但我的代碼無法通過W3C validation。我得到了一個錯誤
there is no attribute "data-show-count" …witter-follow-button" data-show-count="false">Follow @shree</a><script typ…
我搜索和查找this solution但無法理解如何實現與我code.Thanks這一解決方案。

回答

1

因爲數據屬性是HTML 5 spec的一部分。使用<!DOCTYPE html>指定HTML 5 DOCTYPE從here

OR

兩者

把你的鏈接代碼到文件撰寫,所以你必須

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>"); 
+0

如何使用'我的代碼中的<!DOCTYPE html>'有什麼想法? – 2012-04-09 06:26:30

+0

只能在整個頁面上設置文檔類型 – 2012-04-09 07:05:31

+0

查看編輯 – 2012-04-09 07:17:22