Controlling Sounds with JavaScript
<html>
<head>
<title>JavaScript Unleashed</title>
<script type="text/javascript">
<!--
function playSound(sfile) {
// load a sound and play it
window.location.href=sfile;
}
//-->
</script>
</head>
<body onLoad="playSound('yourFile.wav')" onUnLoad="playSound('Glass.wav')">
<a href="#" onClick="playSound('Cashreg.wav')">
Click here for sound
</a>
<p>
<form name="form1">
<input type="button" value="Play" onClick="playSound('Gunshot.wav')">
</form>
</p>
</body>
</html>
Related examples in the same category