Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:20
mouse over sounds
Poster: ccater
Dated: Monday April 21 2008 - 19:58:29 BST
hi all,
I was wondering if it is possible to have a sound happen when you rollover a menu item, and if so, what would the code be?
Thanks
COL
Re: mouse over sounds
Poster: Ruth
Dated: Tuesday April 22 2008 - 20:13:11 BST
Yes, it is.
There are a lot of mouseover codes out there for sound. Most are browser specific. I found one that is cross browser, at least it works in Netscape7.1, 9, Opera 7.1, 7.54, Firebird .07, Firefox 1.0.2, 1.5, 2.0.0.3, IE 5.5, 6. I can't get it to work in Netscape6 or 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. I do not have mac so am unable to test for that OS.
So, to set up sound on mouseover you'd put this at the top of the menu data file
Code:
function DHTMLSound(surl) {
document.getElementById("dummyspan").innerHTML=
"<embed src='"+surl+"' hidden=true autostart=true loop=false>";
}
document.getElementById("dummyspan").innerHTML=
"<embed src='"+surl+"' hidden=true autostart=true loop=false>";
}
Then in the aI string where you want the sound on mouseover you'd call it like this
Code:
aI("text=Home;url=http://www.milonic.com/;onfunction=DHTMLSound('success.wav');");
Finally, you need to place a 'dummy' span on every page where you want it to work.
Code:
<span id=dummyspan></span>
If no span is posted, the sound won't play and an error message will be given that document.getElement is null or not an object.
I do not know js functions but it would seem that for someone who does it would be possible to edit the sound function to add an if/else statement so no error message is generated if no span is on the page. Something where you tell it if the dummy span is there then play the sound, else no sound.
Ruth