You are here: Reference > JavaScript > client-side > HTML DOM > properties > balance (bgsound)

balance property (bgsound)

Browser support:
Specifies or returns how the volume will be divided between the left and right speakers.

Syntax:

object.balance;
You can find the related objects in the Supported by objects section below.
This property is read/write.
HTML page for this property: balance

Possible values:

Integer between -10,000 and +10,000. Default:0. Negative values mean the left speaker is dominant, positive values mean the right speaker is dominant.
Default: 0.

Example HTML code 1:

This example illustrates the use of the balance attribute:
<bgsound src="budgie.wav" loop="-1" balance="10000">
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates the use of the balance property:
<head>
    <script type="text/javascript">
        function ChangeBalance (elem) {
            var soundTag = document.getElementById ("soundTag");

            // Returns the index of the selected option
            var whichSelected = elem.selectedIndex;

            // Returns the text of the selected option
            var balanceNr = elem.options[whichSelected].text;

            if ('balance' in soundTag) {
                soundTag.balance = balanceNr;
            } else {
                alert ("Your browser doesn't support this example!");
            }
        }
    </script>
</head>
<body>
    <bgsound id="soundTag" src="budgie.wav" loop="-1" balance="10000">

    Change the selected element in the next list to hear the difference.

    <br /><br />

    <select id="mySelect" onchange="ChangeBalance (this);">
        <option selected="selected">10000
        <option />8000
        <option />6000
        <option />4000
        <option />2000
        <option />0
        <option />-2000
        <option />-4000
        <option />-6000
        <option />-8000
        <option />-10000
    </select>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content