Click to See Complete Forum and Search --> : Adding sound to buttons and links


Ribeyed
05-28-2003, 03:47 AM
Hi,
can anyone show me the code i need to add sound to a button and/or a link?

Nevermore
05-28-2003, 03:56 AM
That depends on what you want it to do. If all you want is to link to a sound, you can use HTML, whereas if you want, say, to play a sound for a few seconds then load a new page, you need JavaScript. Which will it be?

Ribeyed
05-28-2003, 03:57 AM
play for a few seconds then load new page :D

Nevermore
05-28-2003, 04:00 AM
Always the same music, or different music for different links?

Ribeyed
05-28-2003, 04:01 AM
HI,
more of a checkout sound playing for a few seconds when the user clicks a button called add to cart

Nevermore
05-28-2003, 04:10 AM
Here's what you need:

Put this in the head of the document:

<script type="text/javascript">
<!--
function playango(togo) {
go=togo;
window.setTimeout("document.location.href=go",2000);
document.embeds['0'].play();
}
// -->
</script>

Then put this in the body, replacing the src of it with the source of your music:
<embed src="yourtune.wav" hidden=true autostart=false>

Then link to your add to cart page like this:

<a href="cart.html" onclick="playango('cart.html');return false; ">Add to Cart</a>

Making sure that you put the new URL in the href AND the brackets in playango().

Ribeyed
05-28-2003, 04:43 AM
Great! will try that thanks