Forum Moderators: open

Message Too Old, No Replies

onClick sound

can not make it right

         

henry0

2:02 pm on Dec 1, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a request to generate an onClick event (sound) for a specific link.
I am not a JS coder, so I searched and found something that looks to make sense.
But it does not work, it seems that the most recent MS updates do not allow such scripts to run? Any clue?
<<<
<html>
<bgsound src="#" id="soundeffect" loop=1 autostart="true" />

<script type="text/javascript">

var soundfile="sound/sidebar.wav" //path to sound file, or pass in filename directly into playsound()

function playsound(soundfile){
if (document.all && document.getElementById){
document.getElementById("soundeffect").src="" //reset first in case of problems
document.getElementById("soundeffect").src=soundfile
}
}

function bindsound(tag, soundfile, masterElement){
if (!window.event) return
var source=event.srcElement
while (source!=masterElement && source.tagName!="HTML"){
if (source.tagName==tag.toUpperCase()){
playsound(soundfile)
break
}
source=source.parentElement
}
}

</script>

<a href="#" onMouseover="playsound(soundfile)">Any Link</a>

</html>

>>>

henry0

11:45 am on Dec 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Believe me I hate to bring myself to the top!

But I will appreciate if you could just tell me if it is doable and possibly point me toward a solution
Thanks

Henry

MichaelBluejay

12:58 pm on Dec 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'd never heard of the bgsound tag before. I just looked it up, it's apparently IE-only. Getting sound-on-demand on your web page without using Flash isn't easy, otherwise everyone would be doing it.

Here's an article that might give you some ideas, though: [ask.metafilter.com...]

Fotiman

3:22 pm on Dec 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



SoundManager is an object-oriented library/API which provides a Javascript interface to control sounds loaded in a hidden Flash movie. It's also free:

[schillmania.com...]

Hope that helps.

henry0

4:08 pm on Dec 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thank you very much!
On my way to review the posted links