troubleshooting Question

HTML Embed play() method

Avatar of j0kStA
j0kStA asked on
JavaScript
14 Comments1 Solution10879 ViewsLast Modified:
Hi Guys,

I am fairly advanced with JavaScript, but have been racking my brain with the most simple thing ever, HTML Embed. Basically, I'm trying to use the play() method to play a sound during a certain function. For some reason, it didn't work. So, I wrote a test doc to see if something else was interfering with it. The test doc contained the following code:

<HTML>
<head>
<script>
function EvalSound() {
  document.getElementById('chime').Play();
}
</script>
</head>
<body>
<embed src="http://members.aol.com/bufferm/wav/chime.wav" autostart=false hidden=true id="chime" name="chime">
<form>
<input type="button" value="Play Sound" onClick="EvalSound()">
</form>
<script>
EvalSound();
</script>
</body>
</HTML>

Pretty simple huh? The <script>EvalSound();</script> by itself won't work, but when called from the onClick method, works just fine. Why will it play the sound from a button, but not when the function is called by itself?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 14 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros