Lyd ved MouseOver på mere end et element
Hej EksperterJeg sidder og roder med en hjemmeside til et projekt jeg er igang med, i faget Kommunikation/IT på HTX.
Jeg er nu stødt ind i et problem. Jeg har to figurer, som hver især skal sige en lyd, når man trækker musen over figurene, men jeg kan ikke få det til at virke, jeg har brugt denne metode:
http://www.hypergurl.com/mouseoversound.html
Jeg koder i HTML og min kode ser ud som følgende:
<html>
<head>
<title>vand-land - midterbillede</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
#krokodille {
margin: 1px auto;
padding: 0;
border: 0px;
width:0px;
height:0px;
}
#abe {
margin: 1px auto;
padding: 0;
border: 0px;
width:0px;
height:0px;
}
</style>
<script language="JavaScript">
var aySound = new Array();
aySound[0] = "chimps.wav";
aySound[1] = "baligator3.wav";
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.soundfiles: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); }
</script>
</head>
<body bgcolor="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- Save for Web Slices (vand-land - midterbillede.psd) -->
<table id="Table_01" width="1200" height="938" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td colspan="5">
<div style="position:relative;top:260px;left:-60px" id="abe">
<img src="../../../../../../Projekt Randers Regnskov/images/IMAG0016-100_92.gif" style="position:absolut width="100" height="92"" border="0" name="abe" onMouseOver="playSound(0)" onMouseOut="stopSound(0)">
</div>
<div style="position:relative;top:260px;left:60px" id="krokodille">
<img src="../../../../../../Projekt Randers Regnskov/images/IMAG0017-animation.gif" style="position:absolut width="300" height="334"" border="0" name="krokodille" onMouseOver="playSound(1)" onMouseOut="stopSound(1)">
</div>
<img src="images/vand-land---midterbillede_01.gif" width="1200" height="417" alt="">
</td>
</tr>
<tr>
<td rowspan="2">
<img src="images/vand-land---midterbillede_02.gif" width="105" height="521" alt=""></td>
<td><a href="tempel.html"><img src="images/vand-land---midterbillede_03.gif" width="78" height="86" alt=""></a></td>
<td rowspan="2">
<img src="images/vand-land---midterbillede_04.gif" width="831" height="521" alt=""></td>
<td><a href="vand.html"><img src="images/vand-land---midterbillede_05.gif" width="78" height="86" alt=""></a></td>
<td rowspan="2">
<img src="images/vand-land---midterbillede_06.gif" width="108" height="521" alt=""></td>
</tr>
<tr>
<td>
<img src="images/vand-land---midterbillede_07.gif" width="78" height="435" alt=""></td>
<td>
<img src="images/vand-land---midterbillede_08.gif" width="78" height="435" alt=""></td>
</tr>
</table>
<!-- End Save for Web Slices -->
</body>
</html>
På forhånd tak :)