Lets say we have
<head>
..
..
<meta property="og:description" content="Default Description"/>
..
</hea>
And then
<a onclick="var url=document.location.href; window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(url),'ventanacompartir', 'toolbar=0, status=0, width=650, height=450');"
href="javascript: void(0);" id="fbCompartir" title="" class="mx">
<img alt="compartirFB" src="//d2p65vgzoeytng.cloudfront.net/nPromociones/producto/masNochesMasDescuento/img/icoPromoCompartirFacebook.gif">
</a>
As you can see i am sending to sharer.php vía u parameter the current url, how cand i send a custom text overriding the og:descripion? for example
<a onclick="var url=document.location.href; window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(url)+'&d='+$('#description').text(),'ventanacompartir', 'toolbar=0, status=0, width=650, height=450');"
href="javascript: void(0);" id="fbCompartir" title="" class="mx">
<img alt="compartirFB" src="//d2p65vgzoeytng.cloudfront.net/nPromociones/producto/masNochesMasDescuento/img/icoPromoCompartirFacebook.gif">
</a>
This is just fiction but is there a way to do this?
You can’t do this. Not in javascript anyway – the facebook crawler doesnt read javascript. You will need to put the description you want directly into the url being shared. You could always change the og:description on the server in your php (or whatever server language you use) based on a parameter you send in. Make sure you enumerate them though so users can’t write their own descriptions!