spacer

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

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

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.

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business