spacer

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

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

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, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint