homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

How to make a link make sound?
doe anyone know?

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

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)

thanks MadScientist1, I'm on my way. KG2RG


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

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


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

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)

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)

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)

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!

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved