Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

loop attribute | loop property

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

Syntax

HTML<element loop="loop" ... >
JavaScript

loop = object.loop

Property values

Type: Variant

-1

Loops infinitely.

0

Loops one time.

count

Number of times to loop.

ValueCondition
1

Default. Loops once.

 

Remarks

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.

<bgsound src="file:///c:\win95\system\msremind.wav">Loops one time
<bgsound src="file:///c:\win95\system\msremind.wav" loop>Loops one time.
<bgsound src="file:///c:\win95\system\msremind.wav" loop=>Loops one time.
<bgsound src="file:///c:\win95\system\msremind.wav" loop="0">Loops one time.
<bgsound src="file:///c:\win95\system\msremind.wav" loop="-1">Loops infinitely.

 

Examples

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

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/loop.htm


<!DOCTYPE html>
<html>
<head>
  <title>Loop Property Example</title>
</head>
<body>
  <h1>Loop Property Example</h1>
  <bgsound id="oBGSound" src="http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/media/sfxcategory06.wav" />
  <p>
    When this page loads, a background sound plays once. Click the <strong>Loop Sound Continuously</strong> button to loop the sound continuously. 
    Click the <strong>Loop Sound Once</strong> button to loop the sound only once.
  </p>
  <p>
    <button onclick="loopOnce()">Loop Sound Once</button>&nbsp;
    <button onclick="loopContinuously()">Loop Sound Continuously</button>
  </p>
  <script>
    var oBGSound = document.getElementById('oBGSound');

    function loopOnce() {
      oBGSound.loop = 1;
      oBGSound.src = oBGSound.src; // reload sound
    }
    function loopContinuously() {
      oBGSound.loop = -1;
      oBGSound.src = oBGSound.src; // reload sound
    }
  </script>
</body>
</html>

See also

bgSound
img
input
input type=image

 

 

Show:
© 2014 Microsoft