...

View Full Version : Making a sound when i link is clicked.



Mars
11-05-2002, 02:17 AM
is it possible to play a sound when a link is clicked?

thx alot

-Mars

JustAsking
11-05-2002, 02: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, 06: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, 07:01 AM
Amended code above with stop button!!!

redhead
11-05-2002, 09: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:

Mars
11-06-2002, 05:59 AM
thx a lot for your replies



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum