diTii.com Digital News Hub

Sign up with your email address to be the first to know about latest news and more.

I agree to have my personal information transfered to MailChimp (more information)

Feb012007

Sound with JavaScript but not Flash

Reinier Zwitserloot’s effort to add sound support without embedding a Flash bridge in HTML is successful, he managed to run sound using just JS+HTML. Test Page.


function sound2Play() {
if ( !sound2Embed ) {
sound2Embed = document.createElement("embed");
sound2Embed.setAttribute("src", "machinegun.wav");
sound2Embed.setAttribute("hidden", true);
sound2Embed.setAttribute("autostart", true);
} else sound2Stop();
sound2Embed.removed = false;
document.body.appendChild(sound2Embed);
}

function sound2Stop() {
if ( sound2Embed && !sound2Embed.removed ) {
document.body.removeChild(sound2Embed);
sound2Embed.removed = true;
}
}

Reinier’s Blog

Article, Sound, JavaScript, JS, HTML, Browser, Embeding, Embed, Flash

Share This Story, Choose Your Platform!

Get Latest News

Subscribe to Digital News Hub

Get our daily newsletter about the latest news in the industry.
First Name
Last Name
Email address
Secure and Spam free...