[Javascript] I need to add sound to a button!!
Trey H
tutwabee at hotmail.com
Sun Jun 2 17:47:08 CDT 2002
I would make a script that changes the background sound for each button.
Here is an example of the script:
<bgsound src="#" loop=1 id=bgs name=bgs>
<script>
<!--
function swapSound(sfile) {
document.all.bgs.src=sfile;
}
//-->
</script>
Your button should now look like this:
<a href="APS2.gif" onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Image1','','bbmachines2.gif',1)"
onClick="swapSound('music.wav')"><img name="Image1" border="0"
src="bbmachines1.gif" width="145" height="20"></a>
Remember to substitute the 'music.wav' file in the button code for your own
sound clip in each button
====================================
Trey: tutwabee at hotmail.com
Get free JavaScripts at the Blue Dragon!
Just go to:
http://www.websiter.biz
====================================
Make money by being online:
http://www.degoo.com/index.php?refid=tutwabee
===================================
Earn free traffic for your website easily:
http://tools.addme.com/servlet/popview?id=52260
====================================
>From: morne vermaak <mornevermaak at yahoo.com>
>Reply-To: javascript at LaTech.edu
>To: javascript at LaTech.edu
>Subject: [Javascript] I need to add sound to a button!!
>Date: Sun, 2 Jun 2002 06:32:24 -0700 (PDT)
>
>
>Hello,
>
>I know it is kind of personal for me just to e mail you, but I really do
>need some help on a simple Javascript code, and I am sure that you can help
>me. I created a web site in Dreamweaver. I created my buttons by saving two
>separate GIFs and then I just did a simple rollover code in front of every
>button. It looks fine and it works perfectly. The only problem now is I
>would like to enter sound for every button. In other Words if the viewer
>clicks on the button, he must hear a simple sound efffect. Now getting the
>sound isnt my problem, I dont know how to add sound to that button!!! Here
>is my source code, can you check it out and maybe tell me how to put sound
>in for the buttons. I will REALLY, REALLY appreciate it!
>
>Have a nice day!
>
>Morne
>
>Mornevermaak at yahoo.com
>
><html>
>
><head>
>
><title>Untitled Document</title>
>
><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
>
><script language="JavaScript">
>
><!--
>
>function MM_swapImgRestore() { //v3.0
>
>var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
>x.src=x.oSrc;
>
>}
>
>function MM_preloadImages() { //v3.0
>
>var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
>
>var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length;
>i++)
>
>if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
>
>}
>
>function MM_findObj(n, d) { //v4.0
>
>var p,i,x; if(!d) d=document;
>if((p=n.indexOf("?"))>0&&parent.frames.length) {
>
>d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
>
>if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
>x=d.forms[i][n];
>
>for(i=0;!x&&d.layers&&i<d.layers.length;i++)
>x=MM_findObj(n,d.layers[i].document);
>
>if(!x && document.getElementById) x=document.getElementById(n); return x;
>
>}
>
>function MM_swapImage() { //v3.0
>
>var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;
>for(i=0;i<(a.length-2);i+=3)
>
>if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc)
>x.oSrc=x.src; x.src=a[i+2];}
>
>}
>
>//-->
>
></script>
>
></head>
>
><body bgcolor="#000000" text="#000000"
>onLoad="MM_preloadImages('ABINUS/Buttons/bbmachines2.gif')">
>
><div align="center"><<<<<<this is where I would like the sound to be!!! If
>someone clicks on this button, the sound must play>>>>>>>>>><a
>href="APS2.gif" onMouseOut="MM_swapImgRestore()"
>onMouseOver="MM_swapImage('Image1','','bbmachines2.gif',1)"><img
>name="Image1" border="0" src="bbmachines1.gif" width="145"
>height="20"></a></div>
>
></body>
>
></html>
>
>
>
>regards, mornevermaak at yahoo.com
>
>
>
>---------------------------------
>Do You Yahoo!?
>Yahoo! - Official partner of 2002 FIFA World Cup
_________________________________________________________________
Join the worlds largest e-mail service with MSN Hotmail.
http://www.hotmail.com
More information about the Javascript
mailing list