Hi I have a question about applying sound to onmouseover images. I have some code but this code needs some adjustment and I am not sure how to do it.

<!-- -->

 <!-- //
    var aySound = new Array();
      aySound[0] = "a.mp3";
      aySound[1] = "b.mp3";
      aySound[2] = "c.mp3";
      aySound[3] = "d.mp3";
      aySound[4] = "e.mp3";
      aySound[5] = "f.mp3";
      aySound[6] = "g.mp3";
 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>";
    var Str = '';
        for (i=0;i<aySound.length;i++) Str += "<EMBED SRC='"+aySound[i]+"' AUTOSTART='FALSE' HIDDEN='TRUE'>" if (IE) auEmb.innerHTML = Str;

      auCon = IE? document.all.soundfiles:auEmb; 
      auCon.controll = 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);


<!-- -->

I need to apply sound to images that already has onmouseover images attached. in other words, the image should change and I should hear a sound when the mouse hovers over the image

Thanks jb

1 answer

Mottie 1134
This was chosen as the best answer

Your code appears to be kind of old (Netscape isn't around anymore). The majority of sites that play sounds are using a flash player to do so because playing sound may or may not be supported on all browsers.

I would suggest considering using jQuery. Check out this blog which provides a demo and links to both the jQuery sound and media plugins required.

Answered about 9 years ago by Mottie
  • Thanks but I don't know enough about jquery to use it. I don't know where the path to jquery is. Battle Tested about 9 years ago