Sharer link with parameter in URL

PiTheNumber picture PiTheNumber · Sep 28, 2011 · Viewed 16.3k times · Source

I have a popup window with a Facebook custom share link.

http://www.facebook.com/sharer.php?u=<url to share>&t=<title of content>

How can I use a url u with a parameter like http://google.com/?q=bla? It looks like facebook always cut of the parameter.

Answer

Teddy picture Teddy · Sep 28, 2011

You should URL encode the parameters.

var facebook_url = 'http://www.facebook.com/sharer.php?'+
  'u='+encodeURIComponent('http://google.com/?q=bla')+
  '&amp;t='+encodeURIComponent('Some Page Title');