Adding sound to buttons and links

liunx

Guest
Hi,<br />
can anyone show me the code i need to add sound to a button and/or a link?<!--content-->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?<!--content-->play for a few seconds then load new page :D<!--content-->Always the same music, or different music for different links?<!--content-->HI,<br />
more of a checkout sound playing for a few seconds when the user clicks a button called add to cart<!--content-->Here's what you need:<br />
<br />
Put this in the head of the document:<br />
<br />
<script type="text/javascript"><br />
<!--<br />
function playango(togo) {<br />
go=togo;<br />
window.setTimeout("document.location.href=http://www.webdeveloper.com/forum/archive/index.php/go",2000);<br />
document.embeds['0'].play();<br />
}<br />
// --><br />
</script><br />
<br />
Then put this in the body, replacing the src of it with the source of your music:<br />
<embed src=http://www.webdeveloper.com/forum/archive/index.php/"yourtune.wav" hidden=true autostart=false><br />
<br />
Then link to your add to cart page like this:<br />
<br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"cart.html" onclick="playango('cart.html');return false; ">Add to Cart</a><br />
<br />
Making sure that you put the new URL in the href AND the brackets in playango().<!--content-->Great! will try that thanks<!--content-->
 
Back
Top