1. Home
  2. Computing & Technology
  3. JavaScript

Background Audio

2. Sample

clr gif
Join the Discussion

Questions? Comments?

More of this Feature

Introduction Head Script Body Script

This script places a Background Audio Selector box on your web page that allows your visitors to select one of several sound files that you have on your site and play it in the background.

If your visitors are using a recent browser that properly supports DHTML then the selection box will look like this (non-working example):

Background Audio Selector on recent browsers

With this selector your visitors simply move through your list of music files using the >> and << buttons until the title of the music that they want is displayed above the buttons as a link. Selecting that link will download the associated music file and play it in whatever software that they have installed on their computer that is set to play that type of sound file.

In order that those accessing your page using Netscape 4 can still access all of your music even though their browser doesn't support the dynamic functionality of the selector, visitors using that browser will see the selector contents as a straight list of links to all of your music like this (non-working example):

Background Audio Selector on older browsers

To generate and install this selector box onto your site you need to first copy the head script into your page that will take your array of music files and titles and load them into the selector box.

Explore JavaScript
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. JavaScript

©2009 About.com, a part of The New York Times Company.

All rights reserved.