bgsound | NN n/a IE 4 DOM n/a | |||
A bgsound element defines a sound file that is to play in the background while the user visits the page. Set properties to control the volume and how many times the sound track plays even after the sound file has loaded. A few properties, such as innerHTML and innerText, are exposed in the Windows version, but they don't apply to an element that does not have an end tag. |
||||
HTML Equivalent | ||||
<bgsound> |
||||
Object Model Reference | ||||
[window.]document.getElementById("elementID")
|
||||
Object-Specific Properties | ||||
|
||||
Object-Specific Methods | ||||
None. |
||||
Object-Specific Event Handler Properties | ||||
None. |
balance | NN n/a IE 4 DOM n/a |
Read-only | |
Specifies how the audio is divided between the left and right speakers. Once this attribute value is set in the element, its value cannot be changed by script control. |
|
Example | |
var currBal = document.getElementsByTagName("bgsound")[0].balance; |
|
Value | |
A signed integer between -10,000 and +10,000. A value of 0 is equally balanced on both sides. A negative value means the left side is dominant; a positive value means the right side is dominant. |
|
Default | |
0 |
loop | NN n/a IE 4 DOM n/a |
Read/Write | |
Specifies the number of times the sound plays. Assigning a value of -1 means the sound plays continuously until the page is unloaded. |
|
Example | |
document.getElementById("mySound").loop = 3; |
|
Value | |
Integer. |
|
Default | |
1 |
src | NN n/a IE 4 DOM n/a |
Read/Write | |
Provides the URL of the sound file to be played. Change tunes by assigning a new URL to the property. The new tune plays according to the loop property setting. |
|
Example | |
document.getElementById("tunes").src = "sounds/blues.aif"; |
|
Value | |
Complete or relative URL as a string. |
|
Default | |
None. |
volume | NN n/a IE 4 DOM n/a |
Read/Write | |
Specifies how loud the background sound plays relative to the maximum sound output level as adjusted by user preferences in the client computer. Maximum volumea setting of zerois only as loud as the user has set the Sound control panel. Attribute adjustments are negative values as low as -10,000 (although most users lose the sound at values much higher than that value). |
|
Example | |
var currVolume = document.getElementById("themeSong").volume; |
|
Value | |
Integer. |
|
Default | |
Varies with operating system and sound settings. |