javascript - HTML audio onplay function calling -
i have function 'a', , i'd call function 'b' when audio starts. can call when 'b' has no argument or argument string, it's not working when argument variable.
function a(p){ p.innerhtml= "<audio preload='auto' id='beep1' autoplay='true' onplay='b(p)'><source src='sounds/beep1.mp3' type='audio/mp3' /><source src='sounds/beep1.mp3' type='audio/mp3' /></audio>"; }
that's because p
not defined. inserting string html code. when insert it, variable no longer refers function-specific variable because it's part of html, not function. have define variable separately somehow. if post more code or fiddle, can more.
Comments
Post a Comment