Skip to content

Instantly share code, notes, and snippets.

@divinity76
Created July 23, 2012 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save divinity76/3164792 to your computer and use it in GitHub Desktop.
Save divinity76/3164792 to your computer and use it in GitHub Desktop.
function beep()
{
var audoElement=document.createElement("audio");
document.body.appendChild(audoElement);
audoElement.addEventListener('canplaythrough',function(e){e.target.play();});
audoElement.addEventListener('ended',function(e){e.target.parentNode.removeChild(e.target);});
audoElement.src="http://www.soundjay.com/button/beep-7.mp3";
}
@divinity76
Copy link
Author

Warning: even recent versions of Firefox (firefox 18/14.02.2013) can't play ".mp3" files -.-, get a .ogg-file instead!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment