PerBoman
asked on
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>
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
</BODY>
</HTML>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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
</BODY>
</HTML>
Hope this helps.
ASKER
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)