FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Playing audio on mouse over.

 


abufudail
How do you play sound on mouse over? I don't want to take the user to a different page which shows the embedded player. I guess it is possible by using java script.
niranvv
Try this code dude:
Put onMouseOver="jsPlay('rollimg1sound')" for the link!
And for rollimg1sound specify one source!
And put one javascript for jsPlay() Function!
Im pasting one sample code here!
Try It!



Code:
<html>
<head>
</head>
<bod>
<script language="JavaScript1.4" type="text/javascript">
<!--
function jsPlay(soundobj) {
 var thissound= eval("document."+soundobj);
 try {
     thissound.Play();
 }
 catch (e) {
     thissound.DoPlay();
 }
}
//-->
</script>
<body>
<a onMouseOver="jsPlay('rollimg1sound')" href="index.html">Play Sound</a>
<embed name="rollimg1sound" src="mySoundFile.wav" autostart="false" mastersound hidden="true" volume=100 width=0 height=0></embed>
</body>
</html>
novisdesign
This is a neat little script. Could be used if you put a button that says 'Play Music' or something, so the user doesn't have to here it if they don't want to.
htmlrules
yes you could use a button but would require a bit more code

[url]<html>
<head>
</head>
<bod>
<script language="JavaScript1.4" type="text/javascript">
<!--
function jsPlay(soundobj) {
var thissound= eval("document."+soundobj);
try {
thissound.Play();
}
catch (e) {
thissound.DoPlay();
}
}
//-->
</script>
<body>
<a onClick="jsPlay('rollimg1sound')" href="index.html">Play Sound</a>
<embed name="rollimg1sound" src="mySoundFile.wav" autostart="false" mastersound hidden="true" volume=100 width=0 height=0></embed>
</body>
</html>[/url]
niranvv
htmlrules wrote:
yes you could use a button but would require a bit more code

[url]<html>
<head>
</head>
<bod>
<script language="JavaScript1.4" type="text/javascript">
<!--
function jsPlay(soundobj) {
var thissound= eval("document."+soundobj);
try {
thissound.Play();
}
catch (e) {
thissound.DoPlay();
}
}
//-->
</script>
<body>
<a onClick="jsPlay('rollimg1sound')" href="index.html">Play Sound</a>
<embed name="rollimg1sound" src="mySoundFile.wav" autostart="false" mastersound hidden="true" volume=100 width=0 height=0></embed>
</body>
</html>[/url]


Please quote the things you are copying! Wink
the [ url ] is not for mentioning html tags!
Its for specifying website addresses!
and while quoting codes, you can use [ code ] !!
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.