Foros del Web » Programando para Internet » Javascript »

ejecutar funcion con boton derecho

Estas en el tema de ejecutar funcion con boton derecho en el foro de Javascript en Foros del Web. Mi pregunta es: ¿como puedo hacer para llamar a una funcion pero cuando el usuario presione el boton derecho del mouse?. Algo como Onclick pero ...
  #1 (permalink)  
Antiguo 10/10/2005, 13:28
 
Fecha de Ingreso: septiembre-2005
Mensajes: 10
Antigüedad: 18 años, 7 meses
Puntos: 0
ejecutar funcion con boton derecho

Mi pregunta es: ¿como puedo hacer para llamar a una funcion pero cuando el usuario presione el boton derecho del mouse?. Algo como Onclick pero para el boton derecho.....

Gracias.....
  #2 (permalink)  
Antiguo 10/10/2005, 13:31
Avatar de Saruman  
Fecha de Ingreso: mayo-2003
Ubicación: Panama city, Panama, Panama
Mensajes: 1.154
Antigüedad: 21 años
Puntos: 5
Código PHP:
<script language="JavaScript">
 function 
click() {
  if (
event.button==2) {
   
//pon lo que quieras aqui
  
}
 }
 
document.onmousedown click
</script>
 
saludos
__________________
Saruman

One Ring to rule them all, One Ring to find them, One Ring to bring them all and in the darkness bind them.
  #3 (permalink)  
Antiguo 10/10/2005, 14:20
Avatar de SiR.CARAJ0DIDA  
Fecha de Ingreso: junio-2004
Ubicación: Acá
Mensajes: 1.166
Antigüedad: 19 años, 10 meses
Puntos: 4
eso es solo para internet explorer -_-
__________________
Internet Explorer SuckS
Download FireFox
  #4 (permalink)  
Antiguo 10/10/2005, 14:59
Avatar de Saruman  
Fecha de Ingreso: mayo-2003
Ubicación: Panama city, Panama, Panama
Mensajes: 1.154
Antigüedad: 21 años
Puntos: 5
Cita:
Iniciado por SiR.CARAJ0DIDA
eso es solo para internet explorer -_-
dude, i love your signature... it's kinda cool!!!
__________________
Saruman

One Ring to rule them all, One Ring to find them, One Ring to bring them all and in the darkness bind them.
  #5 (permalink)  
Antiguo 10/10/2005, 17:30
 
Fecha de Ingreso: febrero-2004
Mensajes: 221
Antigüedad: 20 años, 2 meses
Puntos: 0
Código HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<title>Boton izquierdo?</title>
	
	<script type="text/javascript">
		
		boton_izq = function ( ev )
		{
			alert('Jo jo');
			
			// para parar la propagacion del evento en gecko
			if( ev.stopPropagation )
			{
				ev.preventDefault();
				ev.stopPropagation();
			}
			return false;	
		}
		
		// atacha los eventos al cargarse la pagina
		window.onload = function ( )
		{
			html_el = document.getElementsByTagName('html').item(0); 
		
			if( window.attachEvent )
				html_el.attachEvent( 'oncontextmenu', boton_izq );
			else if ( window.addEventListener )
				html_el.addEventListener( 'contextmenu', boton_izq, false );
		}
			
	</script>
</head>

<body>
	Foros del Web
</body>
</html> 
- Crossbrowser
- XHTML 1.0 Strict
__________________
Guillermo Rauch
Freelancer
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 05:40.