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

Preload and play audio files - IE4+, NS4+

Credits: JavaScript Archive


Example:

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

Play sound onMouseOver, onMouseOut
Play sound onClick


How to use this script:

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.wav";
aySound[2]="EvenAnotherOne.wav";
.
.
as many sound files as one wants.
IMPORTANT! Please make sure the sound files exist, or else erros will occur.


Step III - Play the sound files with an event handler.
With a link:
- onMouseOver/onMouseOut sound:
   <A HREF="YourPage.html" onMouseOver="playSound(0)" onMouseOut="stopSound(0)"></A>
- onClick sound:
   <A HREF="javascript:playSound(1);"></A>

With a button:
-
   <INPUT TYPE="BUTTON" VALUE="Click me!" onClick="playSound(1)">

Note: playSound(0) plays the audio file of aySound[0]; playSound(1) will play aySound[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 JavaScript Archive, ©1999