sound on a mouseover

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
wpatters1229
Super Advanced
Super Advanced
Posts: 90
Joined: Thu May 30, 2002 7:35 pm

sound on a mouseover

Post by wpatters1229 »

I know Ruth talked about this about a year ago but I was wondering if with the new menu files there might be an example of using a sound file on a mouseover. I just want to be sure of the script etc..

Thanks
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

Hi,

Yes you can use a script. I've actually found a function that will work to activate sound on mouseover in Netscape7.1, Opera 7.1, 7.54, Firebird .07, Firefox 1.0.2, IE 5.5. I can't get it to work in Netscape6, 4.79. That may be because of whatever audio is used with them. I think 6 wants me to get quicktime, even though I have it set to use windows media player, and 4.79 uses some kind of sound class and beatnik. Anyway, I tried the function with the downloaded menu sample and it worked fine.

In the menu data file add this to the top of the file

Code: Select all

function DHTMLSound(surl) {
  document.getElementById("dummyspan").innerHTML=
    "<embed src='"+surl+"' hidden=true autostart=true loop=false>";
}
I used the Home item to test it

Code: Select all

aI("status=Back To Home Page;text=Home;url=http://milonic.com/;onfunction=DHTMLSound('success.wav');");
Substitute your own sound file.

Finally, on the pages you have to have a dummy span, so you need to add this to all pages someplace where you want it to work.

Code: Select all

<span id=dummyspan></span>
This is the only one I found that works in multiple browsers, even though there were others that said they worked in Netscape and Mozilla, they didn't for me. Hope this helps. You'll have to test in Macs and on other browsers, those are the only ones I have for testing.

Ruth
wpatters1229
Super Advanced
Super Advanced
Posts: 90
Joined: Thu May 30, 2002 7:35 pm

Sound with menu

Post by wpatters1229 »

I appreciate your testing this. The only thing that scares me away from this method is the fact that I have to place some code on each page. I have a site that has over 3000 pages and I just don't want to update all those pages.

Thanks
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

Perhaps someone else would know how to do it by putting it in the menu, but I don't know. What happens if the span isn't on the page is just no sound plays. So maybe you could use it and just put the span on new pages as you do them? But, at least there is a method that seems to be cross browser, well somewhat.

Ruth
Post Reply