Ver Mensaje Individual
  #2 (permalink)  
Antiguo 17/06/2011, 06:57
Avatar de Naahuel
Naahuel
 
Fecha de Ingreso: marzo-2011
Ubicación: localhost
Mensajes: 796
Antigüedad: 13 años, 10 meses
Puntos: 192
Respuesta: ¿Cómo añadir una función a un enlace?

Y podrías hacerlo pasando un hash por el url.
Mirá estos ejemplos:

Llamar a la funcion hola():
http://jsbin.com/ugegu5/6#hola

Llamar a la función adios()
http://jsbin.com/ugegu5/6#adios

Código fuente:

Código HTML:
Ver original
  1. <!DOCTYPE html>
  2.   //llamar a la funcion con el nombre del hash
  3.  eval(location.hash.split('#')[1] + '()');
  4.  
  5.   function hola(){
  6.     alert('hola hola');
  7.   }
  8.  
  9.   function adios(){
  10.     alert('adios adios');
  11.   }
  12.   </script>
  13. </head>
  14.   <p>Llamar a una funcion desde el hash</p>
  15. </body>
  16. </html>
__________________
nahueljose.com.ar