Welcome to WebmasterWorld Guest from

Forum Moderators: incrediBILL

Message Too Old, No Replies

How to make a link make sound?

doe anyone know?



4:08 am on Sep 13, 2001 (gmt 0)

10+ Year Member

How can I ad sound to links and have the sound start=mouseover the link?

And were can I find some sound files (wav, mid, ect.) for this
thanks in advance, KG2RG


7:02 am on Sep 13, 2001 (gmt 0)

There a script here that will do what you want: [codebrain.com...]

JavaScript Sound Kit #053100


1:27 pm on Sep 13, 2001 (gmt 0)

10+ Year Member

thanks MadScientist1, I'm on my way. KG2RG


2:22 pm on Sep 13, 2001 (gmt 0)

10+ Year Member

MadScientist1, Thank again. That script works great. Just what I was looking for. KG2RG


3:07 pm on Sep 28, 2001 (gmt 0)

10+ Year Member

I toyed with the above script and it works great for mouseovers and mouseouts.

The next question is how to generate a sound when a link is clicked. Here are some things I've tried so far:

<A HREF="foo.htm" onClick="playsound()">

Anything along these lines won't work. Why? It appears that the browser will begin loading the new page before any further JavaScripts can be executed.

<A HREF="JavaScript:Play-Sound-And-Wait-Before-Changing-Page()">

This one works well, but the problem is that if JavaScript is turned off, the link won't work at all (which will incidentally block spiders as well).

<A HREF="foo.htm" onClick="return false; Play-Sound-And-Wait-Before-changing-Page()">

For this one, the "return false" stops the new page from loading immediately, but also seems to stop the second function from running!

<A HREF="foo.htm" onClick="return PlaySound()">

This one might work in theory, but I can't seem to put in a "return true" within a setTimeout delay!

Any other ideas?


3:51 pm on Sep 28, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

What about
<A HREF="#" onClick="playsound()">

# is just an empty anchor, so the link goes nowhere.


3:57 pm on Sep 28, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

order the scripting so that the link is only called after the sound is made.

function goClick(href)
window.location.href = href;

<a href="javascript:goClick('www.webmasterworld.com')">WmW</a>

Whilst this works, it isn't very spider friendly!


4:26 pm on Sep 28, 2001 (gmt 0)

10+ Year Member

Wow! Talk about quick responses!

Yep, I am worried about spider friendliness. I also think that a growing number of people are surfing with JavaScript turned off (such as me :)) because of the chronic number of popup ads plaguing the net. So purely JavaScript links aren't the best way to go.

I've had a little success with this one.:

function go-to-foo() {
document.write('<A HREF="JavaScript:playsound();go-to-foo()">
<NOSCRIPT><A HREF="foo.htm"></NOSCRIPT>Click here</A>

Works fine in MSIE, but...
- Nesting error may trip up some browsers or spiders.
- You can't put a quote inside a quote inside a quote, so none of the functions in HREF can have arguments.
- No sound comes out with NN4.7 (possibly the original Codebrain script, possibly because I'm running it locally)
- Fails miserably in Opera. GetRight butts in, and the link is no longer clickable...

I'm still working on it, but if anyone has any good ideas, I'm all ears!


Featured Threads

Hot Threads This Week

Hot Threads This Month