Link to home
Start Free TrialLog in
Avatar of Panos
PanosFlag for Germany

asked on

onclick is working in explorer but not in firefox

Hello experts.
I have a nice working onclick and onmouseover function but it is not working in firefox
Any help?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<bgsound src="#" id="soundeffect" loop=1 autostart="true" />
 
<script type="text/javascript">
 
/***********************************************
* JavaScript Sound effect- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
***********************************************/
 
var soundfile="sounds/click4.mp3" //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>
</head>
 
<body>
<a href="#" onMouseover="playsound(soundfile)">Example 1</a>
<form>
<input type="button" value="Play Sound" onClick="playsound(soundfile)">
</form>
<a href="#" onMouseover="playsound('sounds/click.wav')">Example 2</a>
<div id="coolmenu" onMouseover="bindsound('A', soundfile, this)">
<a href="http://www.cssdrive.com">CSS Drive</a>
<a href="http://www.dynamicdrive.com"">Dynamic Drive</a>
<a href="http://www.javascriptkit.com">JavaScript Kit</a>
<a href="http://www.wired.com">Wired news</a>
<a href="http://www.codingforums.com">Coding Forums</a>
</div>
</body>
</html>

Open in new window

Avatar of TName
TName

Hi, "bgsound" is IE only. Also you are checking for "document.all", which is also Microsoft proprietary code...
Avatar of Panos

ASKER

Hi TName.
Do you mean that this is not working on firefox?
ASKER CERTIFIED SOLUTION
Avatar of TName
TName

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Panos

ASKER

Thank you for your help
regards
panos