Forum Moderators: not2easy

Message Too Old, No Replies

hover sound

need correct code

         

DarkAngel

3:25 am on Aug 12, 2003 (gmt 0)

10+ Year Member



hey!

im trying to get the hover sound to work...
this is my current code - im totally lost im not sure how to put my code in!

<STYLE>
<!--BODY {background: #C6CEFF no-repeat;}td { font-family: verdana; font-size: 9pt; }p
{ font-family: verdana; font-size: 9pt; }.nav {color: #000000; text-decoration: none }.nav2
{color: #000000; text-decoration: none ; border-bottom: #000000; border-width: 1px 1px 1px
1px; border-style: dotted dotted dotted dotted;}A:hover { color: #FF4200; text-decoration:
none; }-->
</STYLE>

i changed my sound file to the "au format" but i need some serious help making it work!
THANKS IN ADVANCED!

MWpro

4:58 am on Aug 12, 2003 (gmt 0)

10+ Year Member



Welcome to WebmasterWorld.

I don't see anything in your CSS that has anything to do with sound at all... Can you clarify what exactly you are asking?

DarkAngel

6:09 am on Aug 12, 2003 (gmt 0)

10+ Year Member



i need to know what the code for the hover sound is and where to put it in my code!

sorry!

garann

6:24 pm on Aug 12, 2003 (gmt 0)

10+ Year Member



I don't know what a hover sound is, so I'm just taking a stab:


<STYLE>
<!--BODY {background: #C6CEFF no-repeat;}td { font-family: verdana; font-size: 9pt; }p
{ font-family: verdana; font-size: 9pt; }.nav {color: #000000; text-decoration: none }.nav2
{color: #000000; text-decoration: none ; border-bottom: #000000; border-width: 1px 1px 1px
1px; border-style: dotted dotted dotted dotted;}

A:hover { color: #FF4200; text-decoration: none; cue-after: url("beep.au");}-->
</STYLE>

If that doesn't help, perhaps this CSS-Aural reference [w3schools.com] will.

devvie

10:18 pm on Aug 12, 2003 (gmt 0)

10+ Year Member



Hi there DarkAngel,

The "cue-after" is only for aural browsers (for the visually impaired).
-----

Without CSS, but with some JavaScript, I got it working (on IE that is; I'm not sure 'bout other browsers)

<a href="http://www.something.org/" onMouseOver="hoversound.play()">test hover sound</a>
<embed name="hoversound" src="gong.wav" autostart="false" loop="false" volume="150" hidden="true" />

If the duration of the sound is too long, you can add

onMouseOut="hoversound.stop()"

<John DeVie />

DarkAngel

11:29 am on Aug 13, 2003 (gmt 0)

10+ Year Member



Hi Devvie

oneee more question pls!

this is my code
<TR><TD WIDTH=200 BGCOLOR="#C6CEFF">&nbsp;<center><a class=naw href="main.htm" target="main">
<B>Main</a></B></TD></TR></center>

Where do i fit your code in?
does it work with the "au format"? coz apparently from some site i was looking at, to make a hover work u need to change the format to "AU" is that correct?

sorry im sooo slow!

ehehe :)

devvie

2:38 pm on Aug 13, 2003 (gmt 0)

10+ Year Member



You put the mouseover (and the mouseout if wanted) as an attribute in the <a>-tag, like so:

<a class=naw href="main.htm" target="main" onMouseOver="hoversound.play()">

The <embed>-tag can go anywhere in the body, since it doesn't show to the users (hidden="true").

As for the sound format...
WAV DOES work. And surely it must work with any AU-file as with any WAV-file. The only problem is when a user doesn't have an application installed that can play that specific format of sound file. He or she does not hear the hover sound.
I, for instance, can not play AU-files.

WAV and MP3 are much better 'covered' worldwide than AU.

<John DeVie />

DarkAngel

5:51 am on Aug 17, 2003 (gmt 0)

10+ Year Member



Thanks Devvie

but its still not working!

<embed name="hoversound" src="hov.wav" autostart="false" loop="true" volume="150" hidden="true" />

if i change the above code to autostart="true"

it does make the noise But i didnt mouse over on the link!

whats going on?

I did change the format from AU to WAV.

Thank you soo much!

MonkeeSage

6:43 am on Aug 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



DarkAngel:

I can't get the play() method to work either (I also tried Play(), play(false), play(true), run(), Run(), and various others that I find from Googling -- none of them worked for me). I think it might be because I have QuickTime installed and associated with wav files. In any case I played around with a DOM2 way of doing it by just creating and inserting the embed element itself on mouseover, then stopping and destroying it with a timer. I'm not sure if this will work for your purposes but here is what I came up with.

In the head of the document:

<script type="text/javascript">
<!--
var tmr = null, ebd = null;
function makeSound(file) {
if (!ebd) {
var snd = document.createElement('embed');
snd.setAttribute("name", "hoversound");
snd.setAttribute("id", "hoversound");
snd.setAttribute("src", file);
snd.setAttribute("autostart", "true");
snd.setAttribute("loop", "true");
snd.setAttribute("volume", "150");
snd.setAttribute("hidden", "true");
document.getElementById("sound-holder").parentNode.appendChild(snd);
if (tmr) {
clearTimeout(tmr);
}
tmr = setTimeout('killSound()', 2000);
ebd = true;
}
else {
clearTimeout(tmr);
killSound();
return makeSound(file);
}
}
function killSound() {
document.getElementById("sound-holder").parentNode
.removeChild(document.embeds['hoversound']);
ebd = null;
}
//-->
</script>

* Increase the 2000 in the line

tmr = setTimeout('killSound()', 2000);
to make it loop longer (2000 = 2 seconds).

In the body:

<span id="sound-holder">
<a href="http://www.something.org/" onMouseOver="makeSound('hov1.wav');">test hover sound</a><br />
<a href="http://www.something.org/" onMouseOver="makeSound('hov2.wav');">test another hover sound</a>
</span>

Somewhat kludgy...but I was bored and mabye it will be useful to someone, somewhere, sometime... :)

Jordan

DarkAngel

11:13 am on Aug 17, 2003 (gmt 0)

10+ Year Member



Thanks Jordan

But that doesnt work for me either.... :(

i am using IE... i dont know why its not working!

another problem tho.

i have some background music on this site im making and some people can hear it and some people cant hear any music at all. they say its not running slowly they just dont hear nething.
What could be the problem?