Link sharing on Facebook

0

I am making a system for my course and found a big problem in the part where I should share the link of the site directly on Facebook.

I have the button on my site that opens directly to the Facebook publishing window, I am sending this link to be shared:

http://localhost/BAC....pag=lerMais.php?&codigo=3

But when the link goes to Facebook, I click on it to open it, but the link just goes:

http://localhost/BAC...pag=lerMais.php

That is, it erases &codigo=3 . How to fix this error?

function mensagem (codigoConteudo) {
    var link = "http://www.facebook.com/sharer.php?u=http://localhost/BACKUPS_TCC/09/Sistema3009/areaAdm.php?pag=lerMais.php&codigo="+codigoConteudo;
    window.open(link, 'facebook_share', 'height=320, width=640, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no',"gl");
}
    
asked by anonymous 30.09.2014 / 22:16

1 answer

3

I get the impression that this is because the passed value (which is a whole URL) is not properly encoded for URLs. Try:

var link = "http://www.facebook.com/sharer.php?u=" + encodeURIComponent("http://localhost/BACKUPS_TCC/09/Sistema3009/areaAdm.php?pag=lerMais.php"+codigoConteudo);
    
30.09.2014 / 22:42