Facebook Like/share Current Url
I have been trying to solve this for a few days now. Basically I have a like/share button on my site generated using the facebook developer tool. So it is very standard. But I can'
Solution 1:
1) Must be <%=
data-href="<%=Request.Url.AbsoluteUri%>"
2) You could do
<div id="sharebutton"
...
window.onload = function () {
var currentUrl = window.location.href;
document.getElementById("sharebutton").setAttribute("data-href", currentUrl);
}
-- or using jquery
jQuery(document).on('ready', function($){
var url = window.location;
$('.fb-like col-xs-offset-1').attr('data-href', url);
});
3) Leaving data-href "" blank worked before v2.0 of social plugin
You can't share localhost. You need to test your share-button on production server where you would have real URL
Post a Comment for "Facebook Like/share Current Url"