I've been trying really hard to make the Facebook share button work, but no luck. I'd like to have the same code on ALL my pages, so I need to be able to dynamically get the current page url and append it to the Facebook share URL.
The best I could come up with is the following:
<a href="" onclick="window.open('http://www.facebook.com/share.php?u=' +
encodeURIComponent(location.href))">Share this page</a>
https://jsfiddle.net/08x2sufs/2/
However, as you can see from the jsFiddle demo, the link does take us to a Facebook share page, but there is no page to share.
Thank you for your help.
https://fiddle.jshell.net/08x2sufs/2/show/
here, and Facebook’s scraper can’t read that URL. Try it under “real” conditions, on a page you know the FB scraper can read properly. (And if in doubt, use developers.facebook.com/tools/debug to find out.)