Link sharing on Facebook

Asked

Viewed 395 times

0

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

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

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

However, when the link goes to Facebook, I click on it to open it, but the link will only:

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

I mean, he erases the &codigo=3. How to fix this mistake?

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");
}

1 answer

3

I get the impression that it is because the value passed (which is an entire URL) is not properly encoded for URL. Try:

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.