View Full Version : Making a sound when i link is clicked.
is it possible to play a sound when a link is clicked?
thx alot
-Mars
JustAsking
11-05-2002, 01:49 AM
Use the code below and it should work fine for you.
Remember to link the src="" to the sound file you want to play.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<head>
<SCRIPT LANGUAGE=JavaScript>
function playSound(){
document.music.play();
}
</SCRIPT>
</head>
<body>
<EMBED SRC="sound file" autostart=false HIDDEN=TRUE NAME="music" MASTERSOUND>
<a href="#null" onclick="playSound();return false">PUT YOUR LINK HERE TO PLAY SOUND</a>
<input type="button" value="Stop music" onclick="music.stop()">
</body>
</html>
ADDED STOP BUTTON TO CODE
zoobie
11-05-2002, 05:08 AM
Always put an 'off' button/link in your page in case your visitor doesn't like your 'wonderful' muzik/sounds. :D
JustAsking
11-05-2002, 06:01 AM
Amended code above with stop button!!!
redhead
11-05-2002, 08:20 PM
heres a script for onmouseover... could be easily changed to onclick, although... if the link is to another page the user will be gone before they can enjoy it...
http://www.javascriptkit.com/script/script2/soundlink.shtml
:thumbsup:
thx a lot for your replies
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.