This page is Not Ready

Notice: The WebPlatform project has been discontinued when the Stewards partnership agreement ended in September 2015. This site has been frozen, and the assets we have created will remain.



Sets or retrieves the number of times a sound or video clip will loop when activated.

Applies to ?
## Examples

This example uses the loop property and the src property to change the number of times a background sound loops.

function loopOnce() {
    oBGSound.loop = 1;
    oBGSound.src = oBGSound.src; // reload sound
function loopContinuously() {
    oBGSound.loop = -1;
    oBGSound.src = oBGSound.src; // reload sound
<BGSOUND id="oBGSound" src="sound.wav">
<BUTTON onclick="loopOnce()">Loop Sound Once</BUTTON>
<BUTTON onclick="loopContinuously()">Loop Sound Continuously</BUTTON>

View live example



To restart a sound or video clip after changing its loop property, set the src property or dynsrc property to itself. For example:

oBGSound.src = oBGSound.src

The following are descriptions of how the loop property works for some boundary cases. {


See also

Related pages

  • bgSound
  • img
  • input
  • input type=image