Playing sounds on a website

  Awestruck 16:49 22 Jun 08

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 08

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.

Intel Coffee Lake 8th-gen Core processors release date rumours

1995-2015: How technology has changed the world in 20 years

Framestore’s haunting post-WWII title sequence for new BBC series SS-GB

How to install MacOS Sierra on an older Mac: Get Sierra running on Macs & MacBooks from before 2009