Click to See Complete Forum and Search --> : Add Sound to mouse overs


Kaisa
12-28-2002, 10:08 PM
I already got the mouseover script for javascript now all i need to know is how to add sound to it (Look At File !)

Zach Elfers
12-28-2002, 10:22 PM
What if you did:

<head>
<script language="JavaScript" type="text/JavaScript">

img1 = new Image(height, width);
img1.src = "img1.ext";
img2 = new Image(height, width);
img2.src = "img2.ext";

</script>
</head>
<body>
<a href="nowhere.html" onMouseOver="document.image1.src = 'img2.ext';playSound('file.wav', '1');" onMouseOut = "document.image1.src = 'img1.ext';playSound('quiet.wav', '1');"><img name="image1" src="img1.ext"></a>

<script language="JavaScript" type="text/JavaScript">

function playSound(file, loop);
document.writeln("<bgsound src=\"" + file + "\" loop=\"" + loop + "\">");
return true;
}

</script>
</body>

Kaisa
12-28-2002, 10:37 PM
I found something like that in the HTMl book i had it had the following code

<HTML><HEAD><TITLE>Llumi's big cat dreams<TITLE>

<SCRIPT LANGUAGE="javascript">

<!--

littlecat = new image(143,83)
littlecat.src = "Real.jpg"
bigcat = new image(143,83)
bigcat.src = "dream.jpg"

// -->

</script></head></body>

Point at Llumi to see what she's thinking.

<a href="nowhere.html"
Onmouseover = "document.catpic.src = bigcat.src"
Onmouseout = "document.catpic.src = littlecat.src">

<img src="real.jpg" name="catpic" width=143 height=83>

</a>

</body><html>

Thats how it showed it in my book but it never worked !

Kaisa
12-28-2002, 10:41 PM
Originally posted by Zach Elfers
What if you did:

\
/

function playSound(file, loop);
document.writeln("<bgsound src=\"" + file + "\" loop=\"" + loop + "\">");
return true;
}

</script>
</body>

i was just wondering why you need all those "\" ?

Beach Bum
12-29-2002, 12:59 AM
document.writeln("<bgsound src=\"" + file + "\" loop=\"" + loop + "\">");
I have not tried the whole script to see if the idea works, but I do know that bgsound only works in IE.

Kaisa
06-20-2003, 11:31 PM
Originally posted by Zach Elfers
What if you did:

<head>
<script language="JavaScript" type="text/JavaScript">

img1 = new Image(height, width);
img1.src = "img1.ext";
img2 = new Image(height, width);
img2.src = "img2.ext";

</script>
</head>
<body>
<a href="nowhere.html" onMouseOver="document.image1.src = 'img2.ext';playSound('file.wav', '1');" onMouseOut = "document.image1.src = 'img1.ext';playSound('quiet.wav', '1');"><img name="image1" src="img1.ext"></a>

<script language="JavaScript" type="text/JavaScript">

function playSound(file, loop);
document.writeln("<bgsound src=\"" + file + "\" loop=\"" + loop + "\">");
return true;
}

</script>
</body>

But won't you need to make the images with the script like document.img.src=".ext." ?

PeOfEo
06-20-2003, 11:44 PM
<A HREF="YourPage.html" onMouseOver="playSound(0)" onMouseOut="stopSound(0)">Move mouse over to play sound</A>

your link

<script LANGUAGE="JavaScript"><!--


var aySound = new Array();

aySound[0] = "laser.wav";


document.write('<BGSOUND ID="auIEContainer">')
IE = (navigator.appVersion.indexOf("MSIE")!=-1 && document.all)? 1:0;
NS = (navigator.appName=="Netscape" && navigator.plugins["LiveAudio"])? 1:0;
ver4 = IE||NS? 1:0;
onload=auPreload;

function auPreload() {
if (!ver4) return;
if (NS) auEmb = new Layer(0,window);
else {
Str = "<DIV ID='auEmb' STYLE='position:absolute;'></DIV>";
document.body.insertAdjacentHTML("BeforeEnd",Str);
}
var Str = '';
for (i=0;i<aySound.length;i++)
Str += "<EMBED SRC='"+aySound[i]+"' AUTOSTART='FALSE' HIDDEN='TRUE'>"
if (IE) auEmb.innerHTML = Str;
else {
auEmb.document.open();
auEmb.document.write(Str);
auEmb.document.close();
}
auCon = IE? document.all.auIEContainer:auEmb;
auCon.control = auCtrl;
}
function auCtrl(whSound,play) {
if (IE) this.src = play? aySound[whSound]:'';
else eval("this.document.embeds[whSound]." + (play? "play()":"stop()"))
}
function playSound(whSound) { if (window.auCon) auCon.control(whSound,true); }
function stopSound(whSound) { if (window.auCon) auCon.control(whSound,false); }
//-->
</script>


I just saw this on another site. Ok it will play a sound 'lazer.wav' whenver you roll a mouse over a link with the event handler code in it. It also preloads these sounds.
Its pretty nifty give it a try. You should just be able to combine your event handlers though to get the desired affect with an image roll over too though.

Kaisa
06-21-2003, 01:33 PM
Originally posted by PeOfEo
<A HREF="YourPage.html" onMouseOver="playSound(0)" onMouseOut="stopSound(0)">Move mouse over to play sound</A>

your link

<script LANGUAGE="JavaScript"><!--


var aySound = new Array();

aySound[0] = "laser.wav";


document.write('<BGSOUND ID="auIEContainer">')
IE = (navigator.appVersion.indexOf("MSIE")!=-1 && document.all)? 1:0;
NS = (navigator.appName=="Netscape" && navigator.plugins["LiveAudio"])? 1:0;
ver4 = IE||NS? 1:0;
onload=auPreload;

function auPreload() {
if (!ver4) return;
if (NS) auEmb = new Layer(0,window);
else {
Str = "<DIV ID='auEmb' STYLE='position:absolute;'></DIV>";
document.body.insertAdjacentHTML("BeforeEnd",Str);
}
var Str = '';
for (i=0;i<aySound.length;i++)
Str += "<EMBED SRC='"+aySound[i]+"' AUTOSTART='FALSE' HIDDEN='TRUE'>"
if (IE) auEmb.innerHTML = Str;
else {
auEmb.document.open();
auEmb.document.write(Str);
auEmb.document.close();
}
auCon = IE? document.all.auIEContainer:auEmb;
auCon.control = auCtrl;
}
function auCtrl(whSound,play) {
if (IE) this.src = play? aySound[whSound]:'';
else eval("this.document.embeds[whSound]." + (play? "play()":"stop()"))
}
function playSound(whSound) { if (window.auCon) auCon.control(whSound,true); }
function stopSound(whSound) { if (window.auCon) auCon.control(whSound,false); }
//-->
</script>


I just saw this on another site. Ok it will play a sound 'lazer.wav' whenver you roll a mouse over a link with the event handler code in it. It also preloads these sounds.
Its pretty nifty give it a try. You should just be able to combine your event handlers though to get the desired affect with an image roll over too though.


http://net4tv.com/voice/Story.cfm?storyID=3413 i found another way to do a sound mouse over there !

PeOfEo
06-21-2003, 01:44 PM
that doesnt pre-load though :) There are three or four similar but different methods you can use I guess. Similar but bifferent... I guess thats a new peoism right there lol similar but different.

JohnnyGT
01-30-2006, 01:48 AM
Hi there !!

can someone please help me do a mouse sound over for my avatar.
i am not the best of computer literate but know little bits from seing other work on it !

my avatar is a boy on a trike(3 wheeler) doing a drift slide and would like it to have sound if my friends move their mouse over it like tires squeling !! :eek:

could you please help me or do something with it and i could link it to my club site ?

tis is the avatar as i got on this site.
http://i21.photobucket.com/albums/b292/littlemax9/av-34.gif

thanks and could you please respond to me vai email at littlemax9@yahoo.com

regards
Pieter