webdev007
Programmer
- Sep 9, 2005
- 168
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>
>>>
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>
>>>