<div id="test1"><div id="fb-root"></div>
<script src=".js#xfbml=1">
</script>
<fb:ments href="/" num_posts="10" width="739"></fb:ments></div>
Above is the code for facebook ments box. I want to dynamically change the href value to the page on which it is. How can i do it.I do not want the static href value to the page on which it is. How can i do it.I do not want the static href value as it is now. Please help.
<div id="test1"><div id="fb-root"></div>
<script src="http://connect.facebook/en_US/all.js#xfbml=1">
</script>
<fb:ments href="http://www.jewelryfresh./" num_posts="10" width="739"></fb:ments></div>
Above is the code for facebook ments box. I want to dynamically change the href value to the page on which it is. How can i do it.I do not want the static href value to the page on which it is. How can i do it.I do not want the static href value as it is now. Please help.
Share Improve this question edited Aug 26, 2011 at 9:28 mangesh asked Aug 26, 2011 at 7:15 mangeshmangesh 412 silver badges6 bronze badges1 Answer
Reset to default 8You can use div
and then dynamically create its contents with the innerHTML
method in JavaScript
where it will be your fb:ments
tag. You can get the current page with document.location.href
.
After you create the fb:ments
tag dynamically and render it inside the div
, you need to reparse its contents so the XFBML is interpreted. You can do it with the FB.XFBML.parse(YOUR_DIV)
method.
Hope this helps.
var mydiv = document.getElementById("mydiv");
mydiv.innerHTML = "<fb:ments href='" + document.location.href + "' num_posts='10' width='739'></fb:ments>";
FB.XFBML.parse(mydiv);