Free Web Hosting Provider - Web Hosting - E-commerce - High Speed Internet - Free Web Page
Search the Web

Preload and play audio files

Browser requirements: IE4+, NS4+
Credits: JS Archive

Example:

All sound files are taken from the Windows 98® CD-ROM
©1995 Microsoft Corporation.

Play sound onMouseOver, onMouseOut
Play sound onClick


Instructions:

Step I - Copy and paste the following code into the <HEAD> section of your page.
Select All



Step II - Edit the aySound array to preload the sound files.
aySound[0]="YourSoundFile.wav";
aySound[1]="AnotherSoundFile.au";
aySound[2]="EvenAnotherOne.ra";
.
.
as many sound files as one wants.


Step III - Play the sound files with an event handler.

Links:
- onMouseOver/onMouseOut sound:
   <A HREF="javascript:void(0);" onMouseOver="playAudio(0)" onMouseOut="stopAudio(0)"></A>
- onClick sound:
   <A HREF="javascript:playAudio(1);"></A>

Note: playAudio(0) plays the audio file of ayAudio[0]; stopAudio(1) will stop ayAudio[1], etc.


If there are any errors installing or running this script,
please e-mail us at webmaster@jsarchive.8m.com

Back home


designed by JS Archive, 2000