The MARQUEE Element


The <MARQUEE> Element

The <MARQUEE> element is a popular one among Internet Explorer programmers. This element enables you to display scrolling text in an easy way. Here's an example putting a few marquees to work:

(Listing 11-01.html on the web site)
 <HTML>      <HEAD>          <TITLE>              Using the &lt;MARQUEE&gt; element          </TITLE>      </HEAD>      <BODY>          <MARQUEE ALIGN="TOP" LOOP="INFINITE" BEHAVIOR="BOUNCE"              BGCOLOR="#00FF00" DIRECTION="RIGHT">              <H2>                  Marquee number 1              </H2>          </MARQUEE>          <H1>Using Marquees</H1>          <MARQUEE ALIGN="LEFT" LOOP="INFINITE" BEHAVIOR="SCROLL"              BGCOLOR="#FF0000" HEIGHT=40 WIDTH=300 DIRECTION="DOWN">              <H2>                  Marquee number 2              </H2>          </MARQUEE>          <MARQUEE ALIGN="TOP" LOOP="INFINITE" BEHAVIOR="SLIDE"              BGCOLOR="#00FFFF" WIDTH=100% DIRECTION="RIGHT">              <H2>                  Marquee number 3              </H2>          </MARQUEE>      </BODY>  </HTML> 

You can see the results of this code in Figure 11.1; the various marquees are scrolling different ways and in different colors.

Figure 11.1. Using Internet Explorer marquees.

graphics/11fig01.gif

The <MARQUEE> element has a number of properties, methods , and events beyond the core set, and you can see them in Table 11.8.

Table 11.8. The Properties, Methods, and Events of the <MARQUEE> Element (See Chapters 5 and 6 for the JavaScript core HTML properties, methods, and events that also apply to this element.)

Property

Methods

Events

behavior

start

onbounce

bgColor

stop

onfinish

direction

 

onerrorupdate

height

 

onstart

hspace

   

loop

   

scrollAmount

   

scrollDelay

   

trueSpeed

   

vspace

   

width

   

You can find the details on the <MARQUEE> element's properties in Table 11.9, its methods in Table 11.10, and its events in Table 11.11.

Table 11.9. The Properties of the <MARQUEE> Element (See Chapters 5 and 6 for the JavaScript core HTML properties, methods, and events that also apply to this element.)

Property

NS2

NS3

NS4

NS6

IE3a

IE3b

IE4

IE5

IE5.5

IE6

behavior

           

x

x

x

x

 

Read/write

 

Sets or gets how the text scrolls in the marquee. May be set to these strings: "scroll" (the defaultthe marquee will scroll in the direction specified by the direction propertythe text scrolls past the end and then starts over), "alternate" (the marquee's scroll action reverses direction when the text reaches the edge), or "slide" (the marquee scrolls in the direction specified by the direction property, but here the text scrolls to the end and stops).

bgColor

           

x

x

x

x

 

Read/write

 

Specifies the background color of the marquee, as a string. Set to a color triplet or a predefined color name the browser understands. In Internet Explorer 5+, you also can set this property to an expression using setExpression .

direction

           

x

x

x

x

 

Read/write

 

Specifies the direction for the marquee to scroll. Set to one of these strings: "left" (the defaultmakes the marquee scroll left), "right" (makes the marquee scroll right), "down" (makes the marquee scroll down), or "up" (makes the marquee scroll up).

height

           

x

x

x

x

 

Read/write

 

Sets the height of the marquee. Set to an integer value measured in pixels, or a string ending in % to indicate a percentage of the parent element's height.

hspace

           

x

x

x

x

 

Read/write

 

Sets or gets the horizontal margin for the marquee. Set to an integer value measured in pixels. (The default is 0.)

loop

           

x

x

x

x

 

Read/write

 

Sets or retrieves the number of times a marquee will play. Set to 0, -1, or INFINITE to make the marquee play forever, or an integer count to make the marquee play a specific number of times.

scrollAmount

           

x

x

x

x

 

Read/write

 

Sets or gets the number of pixels the text scrolls between each redrawing of the marquee. The default value is 6. Set this property to an integer.

scrollDelay

           

x

x

x

x

 

Read/write

 

Sets or gets the speed of the marquee scroll in milliseconds, giving the time in milliseconds between redrawings of the text. Set to an integer; the default value is 85.

trueSpeed

           

x

x

x

x

 

Read/write

 

Sets or gets a value indicating whether the position of the marquee is calculated using the scrollDelay and scrollAmount properties and the time from the computer's clock. Set to false (the default) to make the marquee measure times based on 60-millisecond ticks of the clock (meaning every scrollDelay value under 60 is ignored, and the marquee advances the amount of scrollAmount each 60 milliseconds) or to true to make the marquee scroll the text by scrollAmount after the number of milliseconds set in scrollDelay .

vspace

           

x

x

x

x

 

Read/write

 

Sets or gets the vertical margin for the marquee. Set to an integer value measured in pixels. (The default is 0.)

width

           

x

x

x

x

 

Read/write

 

This property sets the width of the marquee. Set to an integer to specify a width in pixels, or to a string ending with a percent sign (%) to indicate a percentage of the rule's container (usually the browser's client area) width.

Table 11.10. The Methods of the <MARQUEE> Element (See Chapters 5 and 6 for the JavaScript core HTML properties, methods, and events that also apply to this element.)

Method

NS2

NS3

NS4

NS6

IE3a

IE3b

IE4

IE5

IE5.5

IE6

start

           

x

x

x

x

 

Returns: Nothing

 

Starts scrolling the marquee.

 

Syntax: marquee .start() . Note that this method does not cause the onstart event to occur.

stop

           

x

x

x

x

 

Returns: Nothing

 

Stops scrolling the marquee.

 

Syntax: marquee . stop() .

Table 11.11. The Events of the <MARQUEE> Element (See Chapters 5 and 6 for the JavaScript core HTML properties, methods, and events that also apply to this element.)

Event

NS2

NS3

NS4

NS6

IE3a

IE3b

IE4

IE5

IE5.5

IE6

onbounce

           

x

x

x

x

 

Occurs when the behavior property of the marquee object is set to "alternate" and the contents of the marquee reach the edge of the marquee.

onerrorupdate

           

x

x

x

x

 

Occurs in data-bound objects when an error occurs while updating the data in the data source.

onfinish

           

x

x

x

x

 

Occurs when marquee completes its looping.

onstart

           

x

x

x

x

 

Occurs at the beginning of every loop of the marquee.



Inside Javascript
Inside JavaScript
ISBN: 0735712859
EAN: 2147483647
Year: 2005
Pages: 492
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net