Foros del Web » Programando para Internet » Javascript »

Reproducir onClick=""

Estas en el tema de Reproducir onClick="" en el foro de Javascript en Foros del Web. Como reprocucir un sonido al pulsar. En este botón: Código: <input class="boton" type="submit" name="Submit" value="Enviar" onClick="REPRODUCIR EL SONIDO" onMouseOut="this.style.backgroundColor='#E2EDF7';fuera(this);" onMouseOver="this.style.backgroundColor='#AABBCC';sobre(this);"> Gracias...
  #1 (permalink)  
Antiguo 22/07/2003, 03:18
Avatar de Artepop  
Fecha de Ingreso: noviembre-2002
Ubicación: Fuengirola
Mensajes: 292
Antigüedad: 21 años, 5 meses
Puntos: 1
Reproducir onClick=""

Como reprocucir un sonido al pulsar.

En este botón:

Código:
<input class="boton" type="submit" name="Submit" value="Enviar" onClick="REPRODUCIR EL SONIDO" onMouseOut="this.style.backgroundColor='#E2EDF7';fuera(this);" onMouseOver="this.style.backgroundColor='#AABBCC';sobre(this);">

Gracias
__________________
http://www.mfo.com.es/
  #2 (permalink)  
Antiguo 22/07/2003, 04:03
Avatar de homer  
Fecha de Ingreso: marzo-2003
Ubicación: Madrid
Mensajes: 40
Antigüedad: 21 años, 1 mes
Puntos: 0
<---script externo--->

var aySound = new Array();
aySound[0] = "../sonido/beep.wav";
document.write('<BGSOUND ID="auIEContainer">')
IE = (navigator.appVersion.indexOf("MSIE")!=-1 && document.all)? 1:0;
NS = (navigator.appName=="Netscape" && navigator.plugins["LiveAudio"])? 1:0;
ver4 = IE||NS? 1:0;
onload=auPreload;
function auPreload() {
if (!ver4) return;
if (NS) auEmb = new Layer(0,window);
else {
Str = "<DIV ID='auEmb' STYLE='position:absolute;'></DIV>";
document.body.insertAdjacentHTML("BeforeEnd",Str);
}
var Str = '';
for (i=0;i<aySound.length;i++)
Str += "<EMBED SRC='"+aySound[i]+"' AUTOSTART='FALSE' HIDDEN='TRUE'>"
if (IE) auEmb.innerHTML = Str;
else {
auEmb.document.open();
auEmb.document.write(Str);
auEmb.document.close();
}
auCon = IE? document.all.auIEContainer:auEmb;
auCon.control = auCtrl;
}
function auCtrl(whSound,play) {
if (IE) this.src = play? aySound[whSound]:'';
else eval("this.document.embeds[whSound]." + (play? "play()":"stop()"))
}
function playSound(whSound) { if (window.auCon) auCon.control(whSound,true); }
function stopSound(whSound) { if (window.auCon) auCon.control(whSound,false); }

<----fin script externo---->

<----en el html---->

<input class="boton" type="submit" name="Submit" value="Enviar" onClick="playSound(0)" onMouseOut="this.style.backgroundColor='#E2EDF7';f uera(this);" onMouseOver="this.style.backgroundColor='#AABBCC'; sobre(this);">

<----fin código html---->

Como puedes ver puedes poner en el array varios sonidos por si te interesa poner varios dependiendo de dónde se hace el evento, por eso hay una función de parar el sonido (por ejemplo yo lo tengo con onmouseover y onmouseout).

Un saludo.

Última edición por homer; 22/07/2003 a las 04:06
  #3 (permalink)  
Antiguo 22/07/2003, 08:01
Avatar de Artepop  
Fecha de Ingreso: noviembre-2002
Ubicación: Fuengirola
Mensajes: 292
Antigüedad: 21 años, 5 meses
Puntos: 1
Aja, lo probe y funciona bien:

Esto es para un formulario que al pulsar reproduzca un click y al tesetear otro, osea son sonidos cortos.

Hay alguna forma de hacerlo sin un Script tan largo.

Saludos
__________________
http://www.mfo.com.es/
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:33.