spacer

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

home / experts / javascript / column20


The BGSOUND Tag

Developer News
Mandrake Linux Founder Back, Virtually
Amazon: We're a Technology Company
Sun Expands MySQL With Closed Source

Explorer's <BGSOUND> tag is the simplest way to embed background sound in your page. It may be placed either within the HEAD or the BODY portion of the page. Remember to turn ON your browser's "Play sounds" option, under "Edit"/"Internet-Options"/"Advanced". Here is an html code that will the Aladdin soundtrack ten times, every time you load it:

<HTML>
<HEAD>
<TITLE> testing  </TITLE>
</HEAD>
<BODY>
<BGSOUND SRC="aladdin.mid" LOOP=10>
</BODY>
</HTML>

Similarly, the following HTML code will the X-files soundtrack five times:

<HTML>
<HEAD>
<TITLE> testing  </TITLE>
</HEAD>
<BODY>
<BGSOUND SRC="xfiles.mid" LOOP=5>
</BODY>
</HTML>

Microsoft documents specify more parameters for the <BGSOUND> tag than are currently supported. The following table lists the supported ones:

ParameterDescription
ID="idvalue"An identifier to be used for references in associated style sheet, hypertext links, and JavaScript code. Must begin with a letter and may include underscores. ID should be unique within the scope of the document. If duplicated, the collection of identical-ID elements may be referenced by their ordinal numbers.
LOOP="n"Specifies how many times the sound will loop.
SRC="url"Specifies the URL of the sound file. As shown above, sound files can be in any recognizable format (for example: "midi, wav, au")
VOLUME="n"Determines the loudness of the background sound. Values may range from -10,000 (weakest) to 0 (loudest). Not supported by the MAC.

The following parameters are not supported:

ParameterDescription
BALANCE="n"Determines the division of sound power between the left and right speakers. Valid values are between -10,000 and +10,000, with 0 being perfect balance between the two.
CLASS="classname"The class of the tag to be used for assigning sub-class style sheet.
TITLE="text"Specifies text to accompany the sound.
LANG="language"Specifies the language to be used, in ISO standard abbreviation format.

You can reference the <BGSOUND> element in a JavaScript script. The sound-related properties are balance, loop, src, and volume. The src and loop properties are supported on both the PC and the Mac computers. The volume property is supported only on PC.

To demonstrate the usage of JavaScript for controlling the background sound of a page, here is that will switch between the Aladding and X-files soundtracks every 30 seconds:

<HTML>
<HEAD>
<TITLE> testing  </TITLE>
</HEAD>
<BODY>
<BGSOUND SRC="aladdin.mid" ID="changetrack">
<SCRIPT>
<!--
setInterval("switchMelody()",30000);

function switchMelody(){
  if (document.all.changetrack.src == "aladdin.mid") 
    document.all.changetrack.src = "xfiles.mid"
  else document.all.changetrack.src = "aladdin.mid";
}
//-->
</SCRIPT>
</BODY>
</HTML>

This code does not have any effect on the Mac computer. On Mac, <BGSOUND>'s properties cannot be changed by a JavaScript script in the middle of a soundtrack.

http://www.internet.com

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

Whitepapers and eBooks

Intel Whitepaper: Comparing Two- and Four-Socket Platforms for Server Virtualization
IBM Solutions Brief: Go Green With IBM System xTM And Intel
HP eBook: Simplifying SQL Server Management
IBM Contest: Are You the Next Superstar? Join the "Search for the XML Superstar" Contest to Find Out
Microsoft PDF: Top 10 Reasons to Move to Server Virtualization with Hyper-V
Microsoft PDF: Six Reasons Why Microsoft's Hyper-V Will Overtake Vmware
Microsoft Step-by-Step Guide: Hyper-V and Failover Clustering
Intel PDF: Quad-Core Impacts More Than the Data Center
Intel PDF: Virtualization Delivers Data Center Efficiency
Go Parallel Article: PDC 2008 in Review
Microsoft PDF: Top 11 Reasons to Upgrade to Windows Server 2008
Avaya Article: Communication-Enabled Mashups: Empowering Both Business Owners and IT
Intel Whitepaper: Building a Real-World Model to Assess Virtualization Platforms
  PDF: Intel Centrino Duo Processor Technology with Intel Core2 Duo Processor
Microsoft Article: Build and Run Virtual Machines with Hyper-V Server 2008
Go Parallel Article: Q&A with a TBB Junkie
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
IBM eBook: The Pros and Cons of Outsourcing
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
HP eBook: Guide to Storage Networking
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
webref The latest from WebReference.com Browse >
Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP · Working with the DOM Stylesheets Collection
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Crucial Triples Up With New Three-Channel DDR3 Kits · Meet the Finalists: Excellence in Technology Awards · Tealeaf Offers Insight to Mobile Customer Behavior


Created: May 31, 1998
Revised: May 31, 1998

URL: http://www.webreference.com/js/column20/bgsound.html