Get current page URL and append it to Facebook Share link (with javascript)
<p>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.</p>

<p>The best I could come up with is the following:</p>

<pre><code>&lt;a href="" onclick="window.open('http://www.facebook.com/share.php?u=' + 
encodeURIComponent(location.href))"&gt;Share this page&lt;/a&gt;
</code></pre>

<p><a href="https://jsfiddle.net/08x2sufs/2/" rel="noreferrer">https://jsfiddle.net/08x2sufs/2/</a></p>

<p>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.</p>

<p>Thank you for your help.</p>