Music Off and On --MouseOver,MouseOut

             Hi

Could anyone help me with this.
I want musik to be played when "onMouseOver" a link and the
musik should stop when "onMouseOut".
The code I did here below work but when I do "onMouseOut"
I start a where short empty midi-file , to stop the first one.
Couldn't I just stop the first one without start another,
and how?
And what does the parameter "mastersound" in embed tag do?
Without this it doesn't work at all?

Thank you in advanced / Pelle Sweden
(I want to give this question more points but thats all I have)
<HTML>
 <HEAD>
 <TITLE></TITLE>
 </HEAD>

 <SCRIPT LANGUAGE="JavaScript">
  function start() { document.on.play()}
  function stopp() { document.off.play()}
 </SCRIPT>

<BODY>
 <EMBED NAME="on"  SRC="musik2.mid" HIDDEN=true AUTOSTART=false mastersound></EMBED>
 <EMBED NAME="off" SRC="kort.mid"   HIDDEN=true AUTOSTART=false mastersound></EMBED>

 <A HREF="javascript:void(0)"
          onMouseover="start()"
          onMouseOut="stopp()">Music On/Off</A>

 </BODY>
 </HTML>
PerBomanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Trevor013097Commented:
Okay try this:-

<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<SCRIPT LANGUAGE="JavaScript">
function start()
{
document.the-name.play(false);
}

function stop()
{
document.the-name.play(true);
}
</SCRIPT>


<BODY>

<EMBED SRC="filename.wav" HIDDEN=TRUE AUTOSTART=FALSE NAME="the-name" MASTERSOUND>

<a href="your-link.html"
onMouseover="JavaScript:start();"
onMouseout="JavaScript:stop();">Start Music</A>

</BODY>

</HTML>

This simply changes the play property of the embedded sound when your mouse goes over the link.

Hope this helps
 
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PerBomanAuthor Commented:
I have tried this, it doesn't work on my computer.
The play function do the same regardless off the parameter
"true" or "false" . Why?
/Pelle Sweden
(Why do you have the parameter false on your function start,
 true seems more logic, but neither want work for me)
0
Trevor013097Commented:
Hi Pelle,

Okay the script below works great for me.  It will only work in Netscape 3 or higher and will not work in MSIE 3 or 4, something to do with lack of support for the play() method.

The script uses two functions, one to start and one to stop the music.  The play() part of the start function has the switch false as this tells the music not to loop, if you wanted it to play repeatedly you would replace it with true.

The stop() is used in the second function to stop the music.

<HTML>
<HEAD>
<TITLE></TITLE>
<SCRIPT LANGUAGE="JavaScript">
function start()
      {
      document.music.play(true);
      }

function stop()
      {
      document.music.stop();
      }
</SCRIPT>

</HEAD>



<BODY>

<EMBED SRC="midis/mission.mid" HIDDEN=TRUE AUTOSTART=FALSE NAME="music" MASTERSOUND>
<BR>
<a href="your-link.html"
onMouseover="start();"
onMouseout="stop();">Mouse Sensitive Music</A>

</BODY>

</HTML>

Hope this helps.

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.