Facebook Dynamic share button url(data-href)

For JavaScript:

<script language=”javascript”>
function fbshareCurrentPage()
{window.open(“https://www.facebook.com/sharer/sharer.php?u=”+escape(window.location.href)+”&t=”+document.title, ”, ‘menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600’);return false; }
</script>

 

To call the facebook share button:

<a href=”javascript:fbshareCurrentPage()” target=”_blank” alt=”Share on Facebook”>Facebook</a>

 

Option: If you want a direct link instead of opening a popup window, replace the value of “escape()” to script below:

window.location.href=”https://www.facebook.com/sharer/sharer.php?u=”+escape(window.location.href)+”&t=”+document.title;