it turns out my website has different sections loaded by ajax. I would like for example the contact section to share on facebook, but there is no way to do this since they always shared the index.
The url of my web when ajax load content are well
www.example.com/#contacto
The button that loads ajax content:
<a href="#contacto" onClick="cargarbio('ficha.php','contenido-texto')">CONTACTO</a>
Ajax code:
function nuevoAjax(){
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
// Función para cargar los contenidos de forma asíncrona.
// + pagina: fichero cuyo contenido queremos cargar.
// + identidicador del elemento en el que se cargará el nuevo contenido.
function cargarbio(pagina,destino){
var contenedor;
var ajax;
contenedor = document.getElementById(destino);
ajax = nuevoAjax();
ajax.open("GET", pagina, true);
ajax.onreadystatechange=function() {
if (ajax.readyState==4) {
contenedor.innerHTML = ajax.responseText;
//do Ajaxy stuff here to insert new content into hidden div 'foo' FUN
FB.XFBML.parse(document.getElementById('contenido-texto'), function() {
document.getElementById('yourContent').innerHTML += document.getElementById('contenido-texto').innerHTML;
});
//FUN
}
}
ajax.send(null);
}