Dette virker i IE6 SP1, men jeg ved ikke om det virker i andre browsere:
<HTML>
<HEAD></HEAD>
<body>
<BGSOUND id="BGSOUND_ID" LOOP=1 SRC="
http://www.javascripter.net/faq/sound/jsilence.mid"><EMBED NAME="Bach" SRC="
http://www.nymfo.frip.dk/lose.mp3" LOOP=FALSE AUTOSTART=FALSE HIDDEN=TRUE MASTERSOUND>
<script language="JavaScript"><!--
ver=parseInt(navigator.appVersion)
ie4=(ver>3 && navigator.appName!="Netscape")?1:0
ns4=(ver>3 && navigator.appName=="Netscape")?1:0
ns3=(ver==3 && navigator.appName=="Netscape")?1:0
lyd=1;
function playSound() {
if (ie4 && lyd==1) document.all['BGSOUND_ID'].src='
http://www.nymfo.frip.dk/lose.mp3'; else if (ie4 && lyd==2) document.all['BGSOUND_ID'].src='2.mp3';
else if (ie4 && lyd==3) document.all['BGSOUND_ID'].src='3.mp3';
else if (ie4 && lyd==4) document.all['BGSOUND_ID'].src='4.mp3';
else if (ie4 && lyd==5) document.all['BGSOUND_ID'].src='5.mp3';
else if (ie4 && lyd==6) document.all['BGSOUND_ID'].src='6.mp3';
if ((ns4||ns3) && navigator.javaEnabled() && navigator.mimeTypes['audio/x-mpeg'] && self.document.Bach.IsReady()) {
self.document.Bach.play()
}
}
function stopSound() {
if (ie4) document.all['BGSOUND_ID'].src='
http://www.javascripter.net/faq/sound/jsilence.mid'; if ((ns4||ns3) && navigator.javaEnabled() && navigator.mimeTypes['audio/x-midi']) {
self.document.Bach.stop()
}
}
//-->
</script>
<img src="
http://www.nymfo.frip.dk/mm.jpg" width="100" height="100" border="0" onMouseover="playSound(); lyd=1" onMouseOut="stopSound()">
<img src="
http://www.nymfo.frip.dk/mm.jpg" width="100" height="100" border="0" onMouseover="playSound(); lyd=2" onMouseOut="stopSound()">
<img src="
http://www.nymfo.frip.dk/mm.jpg" width="100" height="100" border="0" onMouseover="playSound(); lyd=3" onMouseOut="stopSound()">
<img src="
http://www.nymfo.frip.dk/mm.jpg" width="100" height="100" border="0" onMouseover="playSound(); lyd=4" onMouseOut="stopSound()">
<img src="
http://www.nymfo.frip.dk/mm.jpg" width="100" height="100" border="0" onMouseover="playSound(); lyd=5" onMouseOut="stopSound()">
<img src="
http://www.nymfo.frip.dk/mm.jpg" width="100" height="100" border="0" onMouseover="playSound(); lyd=6" onMouseOut="stopSound()">
</BODY>
</HTML>
Du kan også bruge dette som burde virke i alle browsere:
<HTML>
<HEAD></HEAD>
<body>
<BGSOUND id="BGSOUND_ID" LOOP=1 SRC="
http://www.javascripter.net/faq/sound/jsilence.mid"><EMBED NAME="Bach" SRC="
http://www.nymfo.frip.dk/lose.mp3" LOOP=FALSE AUTOSTART=FALSE HIDDEN=TRUE MASTERSOUND>
<script language="JavaScript"><!--
ver=parseInt(navigator.appVersion)
ie4=(ver>3 && navigator.appName!="Netscape")?1:0
ns4=(ver>3 && navigator.appName=="Netscape")?1:0
ns3=(ver==3 && navigator.appName=="Netscape")?1:0
function playSound1() {
if (ie4) document.all['BGSOUND_ID'].src='
http://www.nymfo.frip.dk/lose.mp3'; if ((ns4||ns3) && navigator.javaEnabled() && navigator.mimeTypes['audio/x-mpeg'] && self.document.Bach.IsReady()) {
self.document.Bach.play()
}
}
function playSound2() {
if (ie4) document.all['BGSOUND_ID'].src='2.mp3';
if ((ns4||ns3) && navigator.javaEnabled() && navigator.mimeTypes['audio/x-mpeg'] && self.document.Bach.IsReady()) {
self.document.Bach.play()
}
}
function playSound3() {
if (ie4) document.all['BGSOUND_ID'].src='3.mp3';
if ((ns4||ns3) && navigator.javaEnabled() && navigator.mimeTypes['audio/x-mpeg'] && self.document.Bach.IsReady()) {
self.document.Bach.play()
}
}
function playSound4() {
if (ie4) document.all['BGSOUND_ID'].src='4.mp3';
if ((ns4||ns3) && navigator.javaEnabled() && navigator.mimeTypes['audio/x-mpeg'] && self.document.Bach.IsReady()) {
self.document.Bach.play()
}
}
function playSound5() {
if (ie4) document.all['BGSOUND_ID'].src='5.mp3';
if ((ns4||ns3) && navigator.javaEnabled() && navigator.mimeTypes['audio/x-mpeg'] && self.document.Bach.IsReady()) {
self.document.Bach.play()
}
}
function playSound6() {
if (ie4) document.all['BGSOUND_ID'].src='6.mp3';
if ((ns4||ns3) && navigator.javaEnabled() && navigator.mimeTypes['audio/x-mpeg'] && self.document.Bach.IsReady()) {
self.document.Bach.play()
}
}
function stopSound() {
if (ie4) document.all['BGSOUND_ID'].src='
http://www.javascripter.net/faq/sound/jsilence.mid'; if ((ns4||ns3) && navigator.javaEnabled() && navigator.mimeTypes['audio/x-midi']) {
self.document.Bach.stop()
}
}
//-->
</script>
<img src="
http://www.nymfo.frip.dk/mm.jpg" width="100" height="100" border="0" onMouseover="playSound1()" onMouseOut="stopSound()">
<img src="
http://www.nymfo.frip.dk/mm.jpg" width="100" height="100" border="0" onMouseover="playSound2()" onMouseOut="stopSound()">
<img src="
http://www.nymfo.frip.dk/mm.jpg" width="100" height="100" border="0" onMouseover="playSound3()" onMouseOut="stopSound()">
<img src="
http://www.nymfo.frip.dk/mm.jpg" width="100" height="100" border="0" onMouseover="playSound4()" onMouseOut="stopSound()">
<img src="
http://www.nymfo.frip.dk/mm.jpg" width="100" height="100" border="0" onMouseover="playSound5()" onMouseOut="stopSound()">
<img src="
http://www.nymfo.frip.dk/mm.jpg" width="100" height="100" border="0" onMouseover="playSound6()" onMouseOut="stopSound()">
</BODY>
</HTML>