0
votes

I am trying to create an fb share button in my website. When user clicks on button(fb image) it gets redirected to http://www.facebook.com/sharer.php?u=. I m setting url as location.href dynamically through js url is encoded automatically and when i click on button i see http://www.facebook.com/sharer.php?u=http%3A%2F%2F ... url has a parameter x. it is in the form http://website.com/?x= after clicking i get facebook error saying this page isn't working. Unable to handle this request.

i tried encoding location.href through js (encodeURIComponent function) but still it doesn't get affected.

There are ways through fb sdk but i am trying the simpler way. I am using same on twitter and its working fine. (Twitter url is http://www.twitter.com/intent/tweet?text=). After searching on internet i am unable to come up with any solution yet.

Also tried opening http://www.facebook.com/sharer.php?u= and putting url manually. Still i get the error.

1
how you are generating the url?? - Tushar Pal
Hardcoded the first part i.e. FB.com/sharer.... And appending location.href to it using js script @TusharPal - Shubham
<a href="facebook.com/sharer/sharer.php?u=URLENCODED_URL" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600');return false;" try this one i have used it target="_blank" title="Share on Facebook"> </a> - Tushar Pal
this also tried earlier with no luck - Shubham
what error are you seeing in console? - Tushar Pal

1 Answers

1
votes

There was no error in setup. But adding additional tag for og:url which pointed to incorrect url was the problem. Removing meta tag worked.