Displaying Facebook Comments Box with Valid HTML
- 10 October, 2011 -
- Facebook Dev -
- Tags : Facebook, Social Plugins
- 0 Comments
Here is some code that allows you to have a HTML Valid Facebook Comments Box?
Move the Facebook code into a document.write JS function and it will all validate.
<div id="fb-root"></div>
<script type="text/javascript">(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'));
/* <![CDATA[ */
document.write('<div class="fb-comments" data-href="shanejones.co.uk" data-num-posts="2" data-width="500"></div>');
/* ]]> */
</script>