Use Dreamweaver Behaviors to Play
sound, music on Rollover, on Click or on Loading the Page
Sample: Click Here to Play Sound
Learn how to Play Sound in 2 steps
- Create a link for the sound to be played
on Rollover or on Click. You need to make a simple text
link with '#' symbol.
- Then add a behavior to the link. Open Windows/Behaviors
and click on the '+' symbol in the Behaviors Panel. Click
on 'Play Sound'. Browse to find the sound you need to play
and click OK.
Note: If you need to play music on any event, go to the
behaviors panel and select another event from events drop
down menu e.g. to play music on Rollover then you have to
choose onMouseOver
Javascript Code
<script language="JavaScript">
<!--
function MM_controlSound(x, _sndObj, sndFile) { //v3.0
var i, method = "", sndObj = eval(_sndObj);
if (sndObj != null) {
if (navigator.appName == 'Netscape') method = "play";
else {
if (window.MM_WMP == null) {
window.MM_WMP = false;
for(i in sndObj) if (i == "ActiveMovie") {
window.MM_WMP = true; break;
} }
if (window.MM_WMP) method = "play";
else if (sndObj.FileName) method = "run";
} }
if (method) eval(_sndObj+"."+method+"()");
else window.location = sndFile;
}
//-->
</script>
Dreamweaver generates the following code that
embeds the sound file within the page
<embed name='CS1022563046202' src='sound.wav' loop=false
autostart=false MASTERSOUND hidden=true width=0 height=0>
</embed>
This can be included towards the end of the page.
HTML Code
<a href="#" onClick="MM_controlSound('play','document. CS1022563046202','sound.wav')">Click
Here to Play Sound</a>
|