View Full Version : Help with adding sound on mouse-click

suave design
05-16-2011, 10:09 AM
I am trying to add sound to my website, on mouse-click.
I am using Dreamweaver. I went to Behaviors, and clicked "play sound", and chose a sound to play. I have this sound in my local folder, and Dreamweaver inserted it into my code, right after a link.
But the sound does not play when I test it!
Please help asap....
(the link to my site is www.trecall.com.)
here is the html code:
<li><a href="smart_pay.html" onClick="MM_controlSound('play','document.CS1305532951843','Swoosh 3-SoundBible.com-1573211927.wav')">Smart Pay</a></li>- this is the code for the mouse-click.
And this is the code that dreamweaver inserted into the <head>:
<script type="text/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;

05-16-2011, 10:26 AM

The first page in my Google search.

suave design
05-16-2011, 09:15 PM
I tried that, too. It did not work- there is no sound when I test it in the browser.
CAn anyone help please?

05-16-2011, 10:13 PM
This is an incorrect definition for a function:

function playSound('Swoosh 3-SoundBible.com-1573211927.wav') {
I presume it should be

function playSound(soundfile) {

05-17-2011, 05:50 AM
Yeah, your URL is invalid.

suave design
05-17-2011, 10:12 AM
I changed it to
function playSound(soundfile) { as you instructed, and I still don't hear any sounds on mouse-click!
What can be causing this problem?
Here is the link to my site:www.trecall.com (http://www.trecall.com)
Please help! Thank you!!

05-17-2011, 10:42 AM
Your page still shows

function playSound('Swoosh 3-SoundBible.com-1573211927.wav') {

which causes an error.

suave design
05-17-2011, 08:22 PM
Thank you Andrew, it now works, and I hear the sound!
One more thing. I have an animated menu in my site that I would also like to add sound to. (on mouseover) But this menu does not have links. Where would I add the code then? To see what I mean, please go to www.trecall.com (http://www.trecall.com)
This is a sample of one of the tabs on the animated menu:

div class="cc_item" style="z-index:5;">
<div class="cc_content_6"> <img src="images/img2.jpg" alt="" /> <span class="cc_title">Grow <br />
Your Practice</span> <span class="cc_submenu"> <span>Grow Your Practice</span> </span> </div>
Thank you very much!!

05-17-2011, 09:49 PM
Depending which element you want to mouseover it might be

div class="cc_item" style="z-index:5;">
<div class="cc_content_6" onmouseover="playSound('Swoosh 3-SoundBible.com-1573211927.wav');"> <img src="images/img2.jpg" alt="" /> <span class="cc_title">Grow <br />
Your Practice</span> <span class="cc_submenu"> <span>Grow Your Practice</span> </span> </div>

suave design
05-18-2011, 09:02 AM
okay, I actually added it to
<div class="cc_item" style="z-index:6;margin-right:14px;"onmouseover="playSound('Whish-Sith_Mas-494.wav');">
But it does not play right. It's choppy. (Instead of being one steady sound, it's broken up.) Do you know why this could be?
Also, sometimes when I open up the site, the sounds (on both menus) are not heard at all, and sometimes they are. What can be causing this??
Thanks for your help!