La Web del Programador: Comunidad de Programadores
 
    Pregunta:  12087 - REPRODUCIR SONIDO
Autor:  Julio Mejicano
Deseo saber como reproducir un sonido cuando se presione el boton derecho del mouse.

Gracias

  Respuesta:  Joan Lluis Lahoz
De esta forma siempre que pulsen el boton derecho reproducira el wav.
Tambien puedes controlar la llamada a la funcion MostraSls.

function init()
{
document.onmousedown=MostraSls;
if (ns4) document.CaptureEvents(Event.MOUSEDOWN);
}

function EmetSo()
{
document.all['soroll'].src='../imatges/cop.wav'
}

function MostraSls(e)
{
if (ie4)
{
if (event.button==2)
{
EmetSo();
}
}
if (ns4)
{
if (e.wich==2)
{
EmetSo();
}
}
}

<BODY onload="init()">

<BGSOUND ID="soroll">