Solved

Music Off and On --MouseOver,MouseOut

Posted on 1997-07-25
3
523 Views
Last Modified: 2011-10-03
             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>
0
Comment
Question by:PerBoman
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
Trevor013097 earned 50 total points
ID: 1268724
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
 

Author Comment

by:PerBoman
ID: 1268725
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
 
LVL 5

Expert Comment

by:Trevor013097
ID: 1268726
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

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Generate Numbers in JQuery file 11 66
Make options hidden and show just option that is on 1 29
how can i get the string decoded ? 2 28
Access RV042 GUI / Browser Issues 25 48
This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question