Playing sounds on a website

  Awestruck 16:49 22 Jun 2008

One of my web clients requires a sound which is initiated by clicking on a link. Using the standard html method as follows, the sound plays OK.

p> b> a href="somesound.wav">Test sound /a> /b> /p>

However, a player pops up, such as Real Player, or Quick player or Windows media player. How can I prevent any player appearing?

I do not want to use a script on this particular website.



  Forum Editor 18:54 22 Jun 2008

which allows you to use JavaScript to write new HTML code into your page and let it be interpreted by the browser.

What you need to do is to write into a region of the document the HTML of an embedded sound, set to automatically start replay on load. Use a <span> region and write into it using its "innerHTML" attribute:

function DHTMLSound(surl) {
"<embed src='"+surl+"' hidden=true autostart=true loop=false>";
Yo can then create the dummy span region and pass the URL of your sound file to the function to play it via a clickable button:

<span id=dummyspan></span>
<input type="button" value="Play Sound" onClick="DHTMLSound('yoursound.wav')">

The sound will then play with nothing popping up.

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

Honor 9 Lite review

How Social Media has Propelled Political Graphic Design and Art in the Last Decade

The best kids apps for iPhone & iPad 2018

HomePod d’Apple : date de sortie, prix et fiche technique