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

OnePlus 5 review

Alice Saey's mesmerising animation for Dutch singer Mark Lotterman

iPad Pro 10.5in (2017) review

Comment booster votre iPhone ?