You are here: Reference > JavaScript > client-side > HTML DOM > properties > loop (marquee)

loop property (marquee)

Browser support:
Specifies or returns the number of times a marquee is to be played.
Note that the browser support of the loop property in JavaScript and the browser support of the loop attribute in HTML are different. While the loop attribute is supported by all commonly used browsers, the loop property is not supported in Safari and Google Chrome. For details, see Example 2.

Syntax:

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

Possible values:

Integer that sets or retrieves the number of repeats. The 0 and -1 values mean endless repetition. Other negative values are not allowed.
Default: -1.

Example HTML code 1:

This example illustrates the use of the loop attribute:
<marquee id="myMarquee" scrollamount="30" loop="1">Hi There!</marquee>
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates the use of the loop property. Note: if the marquee element stops looping regardless of the new value of the loop property, the marquee will not start again in Opera.
<head>
    <script type="text/javascript">
        var counter = 1;

        function ChangeLoop () {
            var marquee = document.getElementById ("myMarquee");
            counter++;

            if ('loop' in marquee) {
                marquee.stop ();
                marquee.loop = counter;
                marquee.start ();
            } 
            else {  // Google Chrome and Safari
                marquee.setAttribute ("loop", counter);
            }
        }
    </script>
</head>
<body>
    <marquee id="myMarquee" style="width:200px" scrollamount="30" loop="1">Hi There!</marquee>
    <button onclick="ChangeLoop ();">Repeat it!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content