javascript - Play a sound with onclick function (Not working!) -


i'm trying play sound when button pressed. have used function in javascript file

function playsound(soundfile) {     alert('hello');      document.getelementbyid("sound").innerhtml=      "<embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";      } 

the alert('hello') executes , rest won't. don't errors also. not play.

i call function here

<button class="button_start" style="float:left;color:green;" onclick="start();">start</button> 

and start() function here , includes playsound().

function start(){      playsound('bip.mp3');      if (control == -1) alert('please select time , press "set" before starting countdown');     else if (control == 0) { control = 1; timer(); }     //else if (control == 1) alert('your countdown running');     } 

and yes, have in html.

<div id="sound"></div> 

i have tried both chrome , firefox, none works.

i'm desperate since whole page timer , supposed play beep @ end of it.

thanks!


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -