-
Salve a tutti ,
vorrei sapere lo script in javascript x fare in modo che al passaggio del mouse su una scritta o un'immagine si attivi un piccolo file di suono.
La funzione è onmouseover="..." ma che ci va scritto dentro??? E soprattutto è sufficiente tale funzione x ottenere il risultato che chiedo?
In caso contrario che script va inserito in <head>???
Grazie , alla prossima.
-
A beneficio di tutti ... dopo una estenuante ricerca ho trovato quello che cercavo:
Lo script per IE è :
<EMBED SRC="sound_file_name.wav" autostart="false" hidden="true">
<SCRIPT language="JavaScript">
<!--
function playHome()
{
if (document.all)
{
document.all.sound.src = "sound_file_name.wav";
}
}
//-->
</SCRIPT>
<bgsound id="sound">
Put your mouse on the link to hear a sound
<A HREF="http://yoursite.com/page.html" onMouseover="playHome()">HERE</A>
L'unico problema è che se aggiungo anche onMouseclick il Front Page mi dà "Memoria Insufficiente"! Ma forse chiedo troppo!
Ciao alla prossima!
-
Prova questo:
[code:1:4d3a63ff84]<script language="JavaScript">
<!-- // Script Source: www.CodeBrain.com
var audioOn = false;
function audioDo(doWhat,toWhat){
if(audioOn){
var A = eval('document.'+toWhat);
if (A != null){
if (doWhat=='stop') A.stop();
else{
if (navigator.appName == 'Netscape') A.play();
else{
if (document.M == null){
document.M = false; var m;
for(m in A) if (m == "ActiveMovie"){
document.M = true; break;
}
}
if (document.M) A.SelectionStart = 0;
if (document.M) A.play();
}
}
}
}
}
//-->
</script>
[/code:1:4d3a63ff84]
nel body:
[code:1:4d3a63ff84]
<p>
<a href="http://www.codebrain.com" onMouseOver="audioDo('play','RedSphereSou nd')" onMouseOut="audioDo('stop','RedSphereSoun d')">
<img border="0" src="RedSphere.gif" width="100" height="100"></a>
<a href="http://www.codebrain.com" onMouseOver="audioDo('play','GreenSphereS ound')" onMouseOut="audioDo('stop','GreenSphereSo und')">
<img border="0" src="GreenSphere.gif" width="100" height="100"></a>
<a href="http://www.codebrain.com" onMouseOver="audioDo('play','PurpleSphere Sound')" onMouseOut="audioDo('stop','PurpleSphereS ound')">
<img src="PurpleSphere.gif" border="0" WIDTH="100" HEIGHT="100"></a>
</p>
<p>
<embed NAME="RedSphereSound" SRC="RedSphereSoundFile.wav" MASTERSOUND LOOP="false" AUTOSTART="false" AUTOREWIND="true" HIDDEN="true" WIDTH="0" HEIGHT="0">
</p>
<p>
<embed NAME="GreenSphereSound" SRC="GreenSphereSoundFile.wav" MASTERSOUND LOOP="false" AUTOSTART="false" AUTOREWIND="true" HIDDEN="true" WIDTH="0" HEIGHT="0">
</p>
<p>
<embed NAME="PurpleSphereSound" SRC="PurpleSphereSoundFile.wav" MASTERSOUND LOOP="false" AUTOSTART="false" AUTOREWIND="true" HIDDEN="true" WIDTH="0" HEIGHT="0">
</p>
[/code:1:4d3a63ff84]
Devi modificare qualcosina :)
Il codice non è mio (non ci capisco granchè di JS)
la fonte è nella nota in alto