spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

Developer News
Mozilla's Ubquity Mashup: For The Masses?
iPhone Users Just Want to Have Fun
Oops! I Fixed the Linux Kernel
JavaScript Tip of the Week for April 29, 1996: Playing Sound in an HTML Document

Alleluia! There are a at least three basic ways to play a sound, or any kind of file for that matter, right in an HTML document, no plug-ins required. These examples use a sound file called "alleluia.au", which, if you have a JavaScript compatible browser , is probably downloading right before your eyes as you read. Well anyway, here is the immediate method, this is enacted as soon as the browser loads the page:
    window.location = "alleluia.au"
and here is the delayed method, the number you see is the time it waits before loading the sound file, about 10 seconds:
    setTimeout("location = alleluia.au'", 10000)
My personal favorite is the "when document is done loading" method. First, after the <HEAD> tag, put a <SCRIPT> tag and then:
    function PlaySound(){
        window.location = "alleluia.au"
        }
Then in the BODY tag, put the line
    onLoad = "PlaySound()"
I hope you find this useful, because it can be used for a variety of applications, yet it is soooo simple. The timer one is also great for automatically turning pages, but make sure you give people enough time to download all of document and then read it before turning the page.



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Performance Optimizations for High Speed JavaScript · Advanced Web Performance Optimization · Simple Comments Meets OpenID
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Extending Telephony: VoIP Call Recording for Business · U-Verse for Business Has Wi-Fi Perks · Lian-Li Launches New Power Supply Line, Rack Mount Kit and Fan Blower