Foros del Web » Programando para Internet » Javascript »

Ejecutar funcion al presionar boton me gusta

Estas en el tema de Ejecutar funcion al presionar boton me gusta en el foro de Javascript en Foros del Web. Hola a todos alguien tiene idea si se puede ejecutar una funcion javascript al presionar en el boton me gusta de facebook ? Lo unico ...
  #1 (permalink)  
Antiguo 30/06/2012, 17:39
 
Fecha de Ingreso: septiembre-2008
Mensajes: 55
Antigüedad: 15 años, 7 meses
Puntos: 0
Ejecutar funcion al presionar boton me gusta

Hola a todos alguien tiene idea si se puede ejecutar una funcion javascript al presionar en el boton me gusta de facebook ?

Lo unico que probe fue colocarle una id al iframe del boton y asignar la siguiente funcion:

$('#BotonMeGusta').click(function(){
alert("presionado");
});

pero no funciono...
  #2 (permalink)  
Antiguo 30/06/2012, 17:58
Avatar de Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años
Puntos: 834
Respuesta: Ejecutar funcion al presionar boton me gusta

Lo mejor para no perder tiempo es estudiar la documentación:
http://developers.facebook.com/docs/...ent.subscribe/
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<
title>Documento sin título</title>
</
head>

<
body>
<
div><div  id="fb-root"></div><fb:like href="http://www.forosdelweb.com/f13/ejecutar-funcion-presionar-boton-gusta-1001443/" width="120" font="lucida grande" colorscheme="light" data-send="false" data-layout="box_count" style="width:120px; height:60px; float:left;position:relative; "></fb:like></div>

<
script type="text/javascript">
function 
getScript(url,callback){
    var 
js document.createElement('script'),html document.documentElement;
    
js.src url;
    if(
callback){
        if(
js.addEventListener){
            
js.addEventListener('load',callback,false);
        }else{
            
js.onreadystatechange=function(){
                if(
js.readyState=='complete' || js.readyState=='loaded'){
                    
callback();
                }
            }
        }
    }
    
html.insertBefore(jshtml.lastChild);
}
getScript(
    
'http://connect.facebook.net/en_US/all.js#xfbml=1',
    function(){
        
FB.Event.subscribe(
            
'edge.create',
            function(
href,widget){
                
alert(href+'--'+widget);//lo que quieras ejecutar
            
}
        );                                                      
    }
);
</script>

</body>
</html> 
  #3 (permalink)  
Antiguo 30/06/2012, 18:04
Avatar de manuparquegiralda  
Fecha de Ingreso: junio-2012
Ubicación: Barcelona
Mensajes: 241
Antigüedad: 11 años, 10 meses
Puntos: 39
Respuesta: Ejecutar funcion al presionar boton me gusta

Imagino que deberia funcionarte si metes el iframe del boton dentro de un div y a este div le das la propiedad de onclick que te lleve a la funcion.
Código HTML:
Ver original
  1. <div id="botonFace" onclick="funcionJava();">
  2.         <iframe src="............................."></iframe>
  3. </div>
  #4 (permalink)  
Antiguo 30/06/2012, 18:09
Avatar de Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años
Puntos: 834
Respuesta: Ejecutar funcion al presionar boton me gusta

¿manuparquegiralda, por qué no pruebas lo que has sugerido?

Última edición por Panino5001; 30/06/2012 a las 18:25
  #5 (permalink)  
Antiguo 30/06/2012, 19:30
 
Fecha de Ingreso: septiembre-2008
Mensajes: 55
Antigüedad: 15 años, 7 meses
Puntos: 0
Respuesta: Ejecutar funcion al presionar boton me gusta

Cita:
Iniciado por Panino5001 Ver Mensaje
Lo mejor para no perder tiempo es estudiar la documentación:
http://developers.facebook.com/docs/...ent.subscribe/
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<
title>Documento sin título</title>
</
head>

<
body>
<
div><div  id="fb-root"></div><fb:like href="http://www.forosdelweb.com/f13/ejecutar-funcion-presionar-boton-gusta-1001443/" width="120" font="lucida grande" colorscheme="light" data-send="false" data-layout="box_count" style="width:120px; height:60px; float:left;position:relative; "></fb:like></div>

<
script type="text/javascript">
function 
getScript(url,callback){
    var 
js document.createElement('script'),html document.documentElement;
    
js.src url;
    if(
callback){
        if(
js.addEventListener){
            
js.addEventListener('load',callback,false);
        }else{
            
js.onreadystatechange=function(){
                if(
js.readyState=='complete' || js.readyState=='loaded'){
                    
callback();
                }
            }
        }
    }
    
html.insertBefore(jshtml.lastChild);
}
getScript(
    
'http://connect.facebook.net/en_US/all.js#xfbml=1',
    function(){
        
FB.Event.subscribe(
            
'edge.create',
            function(
href,widget){
                
alert(href+'--'+widget);//lo que quieras ejecutar
            
}
        );                                                      
    }
);
</script>

</body>
</html> 
Muchas gracias Panino5001, si había leído la documentación pero sinceramente no sabía como aplicarla bien para lograr el objetivo. El ejemplo que pasaste funciona perfectamente.

Etiquetas: funcion, gusta, presionar, botones
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 10:17.