Hi, I am in serious need to have my webpage play a sound when I put my mouse over an image/link on my site. I have found some code that plays a sound when I mouse over a (<a href=) type link. But I want it to play a sound when I mouseover a .gif image in my page. I’m sure you would only have to change a small part of the code, although I know a little bit about Java & HTML, I couldn’t manipulate the code properly. If someone could help me I would be immensly greatful ?
Here is the code complete with instructions..
[CODE]Sounds when mousing-over a link
What if mousing-over a link on your site produced a sound?
Insert this small JavaScript program in the header of your page:
<script LANGUAGE=”JavaScript”>
<!–
var aySound = new Array();
aySound[1] = “http://nastybeatz.co.uk/Audio/Jungle_Skin_Head.mp3″;
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); }
//–>
</script>
All sounds used on the page are defined in the aySound table. If you want to use more sounds, add a line of this
type:
aySound[0]=”my_sound.wav”;
Replace 0 by the number of the sound in the table and my_sound.wav by the sound file that you want to integrate
(including the full filepath if necessary).
Next, define each of your links as follows:
<A HREF=”YourPage.html” onMouseOver=”playSound(0)” onMouseOut=”stopSound(0)”>Your link here!</A>
Replace 0 by the number of the sound that you
Many thanks in advance..
Peace.