<?xml version="1.0" encoding="iso-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="/lib/xsl/devedge-1.00/article_en.xsl"?>
<nde:article 
  url="/toolbox/examples/2002/xb/xbMarquee/" 
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:nde="http://devedge.netscape.com/2002/de"
  xmlns:ent="http://devedge.netscape.com/2003/ent"
  xml:lang="en"
  >

 <nde:header>

   <nde:title>
      Class xbMarquee
   </nde:title>

   <nde:category>
     Manpage
   </nde:category>

  <nde:pubdate year="2002" month="04" day="21" />
  <nde:moddate year="2002" month="07" day="22" />

  <nde:summary>
      Cross Browser JavaScript Object
      which emulates the Marquee object in
      Internet Explorer
  </nde:summary>

  <nde:authlist>
    <nde:author>
      <nde:authname>Doron Rosenberg</nde:authname>
      <nde:authaffil>Netscape Communications</nde:authaffil>
    </nde:author>
    <nde:author>
      <nde:authname>Bob Clary</nde:authname>
      <nde:authaffil>Netscape Communications</nde:authaffil>
    </nde:author>
  </nde:authlist>

  <nde:channels>
    <nde:channel id="examples"/>
    <nde:channel id="xb-2002"/>
  </nde:channels>

</nde:header>


 <nde:head>
 </nde:head>

 <nde:content>
   <h2>Synopis</h2>
   <pre><![CDATA[
class xbMarquee
{
public:
xbMarquee(String id, 
          String height, 
          String width;
          Number scrollAmount,
          Number scrollDelay,
          String direction,
          String behavior,
          String html);

  // properties
  String id;
  Number height;
  String heightUnit;
  Number width;
  String widthUnit;
  Number scrollAmount;
  Number scrollDelay;
  String direction;
  String behavior;
  String name;
  Number runId;
  HTMLElement containerDiv;
  HTMLElement div;
  Object styleObj;
  String html;
  Boolean isHorizontal;
  Object onmouseover;
  Object onmouseout;
  Object onclick;
  Object onstart;
  Object onbounce;

  // methods
  void start();
  void stop();
  void setInnerHTML(String html);
}

// class Properties
// internal use only
Number xbMarquee._name;
HTMLELement xbMarquee.getElm(String id);
Number xbMarquee._getInnerSize(HTMLELement elm, String propName);
Boolean xbMarquee.dispatchUIEvent(Event event, String marqueeName, String eventName);
String xbMarquee.createDispatchEventAttr(String marqueeName, String eventName);
]]></pre>

    <h2>Source</h2>
    <p>
      <a href="xbMarquee.js">xbMarquee.js</a>
    </p>

    <h2>Uses</h2>
    <ul>
      <li>nothing</li>
    </ul>

    <h2>See Also</h2>
    
    <ul>
      <li>
       <a href="/toolbox/examples/2002/xb/xbAnimatedElement/">xbAnimatedElement</a>
     </li>
     <li>
       <a href="/toolbox/examples/2002/xb/xbPositionableElement/">xbPositionableElement</a>
     </li>
     <li>
       <a href="/toolbox/examples/2001/stock-ticker/">Stock Ticker</a>
      </li>
    </ul>

    <h2>Introduction</h2>
    
    <p>
      &lt;marquee&gt;...&lt;/marquee&gt; is an HTML element invented by Microsoft. 
      It is supported by IE3 and above. The marquee element is not part of the 
      current or past HTML standards. There are no other browsers that currently 
      support the marquee element. For this reason it is not used very often on 
      major web pages.
      The intended effect is to scroll the text data surrounded by the marquee 
      element tags. The scroll may be horizontal or vertical. The direction of 
      the scroll may be either up or down, or from left or from right. 
      In this document, we offer a comprehensive W3C-compliant alternative to 
      the proprietary &lt;marquee&gt; extension. The Javascript library offered 
      here covers all the major uses of &lt;marquee&gt; such as horizontal vs. 
      vertical scroll, direction of text flow (LtoR, RtoL,alternating, up, and 
      down), rate of scroll, etc.
    </p>

    <h2>Description</h2>
      <p>
        xbMarquee is an JavaScript Object that is used to emulate the basic
        functionality of the Marquee Object as defined by Internet Explorer 
        in a cross browser fashion. 
      </p>
      
      <h3>Notes</h3>

      <p>
        <h4>Script Location/Invocation</h4>
        <p>
          xbMarquee uses document.write to emit the HTML required for the emulated Marquee.
          This requires that the xbMarquee be created inside the BODY tag where the Marquee
          is to be located. In addition, due to issues in Internet Explorer and in Netscape Navigator 4, 
          the Marquee must not be started until after the page has completed loading.
        </p>
      </p>

      <p>
        <h4>Cross Browser Support</h4>
      </p>
      <p>
        Fully supports Gecko based browsers such as Netscape 6.x, Netscape 7.x, CompuServe 7.0
        on all platforms. 
      </p>
      <p>
        Supports Internet Explorer 5.5+ on Windows with the exception of language direction rtl. 
      </p>
      <p>
        Supports Internet Explorer 5.5+ on Windows and Internet Explorer 5.1+ on 
        Macintosh with the exception of language direction rtl. 
      </p>
      <p>
        Support for Netscape Navigator 4.x should be dedtined on a case by case basis.
      </p>

      <p>
        <h4>Using CSS to style xbMarquee</h4>
        <p>
          The appearance and language direction of xbMarquee can be governed using
          CSS rules specified for the HTML elements which are used to construct the
          marquee. To style xbMarquee, define CSS rules for the marquee container
          and the marquee itself. If you create an xbMarquee with ID myMarquee,
          then the container for the xbMarquee will have ID myMarqueecontainer
          and the marquee itself with have ID myMarquee. See the CSS
          example for more details.
        </p>
      </p>

      <p>
        <h4>Support for right to left languages (Hebrew and Arabic)</h4>
        <p>
          Using CSS rule direction: rtl; will enable right to left
          langauge xbMarquees. Please see the examples below for more details.
        </p>
      </p>

    <h2>Properties</h2>
    <dl>

        <dt>
          id
        </dt>
        <dd>
          <p>readonly String - ID Attribute to be given to the
            DIV containing the Marquee. Note that the Marquee will be contained 
            in another DIV with ID value IDcontainer
          </p>
        </dd>

        <dt>
          height
        </dt>
        <dd>
          <p>readonly Number - height of the Marquee in pixels
          </p>
        </dd>

        <dt>
          heightUnit
        </dt>
        <dd>
          <p>readonly String - Unit used in constructor for height argument.
            If not specified, defaults to 'px'.
          </p>
        </dd>

        <dt>
          width
        </dt>
        <dd>
          <p>readonly Number - width of the Marquee in pixels.
          </p>
        </dd>

        <dt>
          widthUnit
        </dt>
        <dd>
          <p>readonly String - Unit used in constructor for width argument.
            If not specified, defaults to 'px'.
          </p>
        </dd>

        <dt>
          scrollAmount
        </dt>
        <dd>
          <p>readonly Number - number of pixels to scroll Marquee 
            contents during each increment.
          </p>
        </dd>

        <dt>
          scrollDelay
        </dt>
        <dd>
          <p>readonly Number - number of milliseconds to wait
            between each increment.
          </p>
        </dd>

        <dt>
          direction
        </dt>
        <dd>
          <p>readonly String - direction the Marquee will move it's
            contents. Possible values are 'left', 'right', 'up', 'down'.
          </p>
        </dd>

        <dt>
          behavior
        </dt>
        <dd>
          <p>readonly String - dedtines the behavior of the Marquee.
            Possible values are 'scroll' and 'alternate'. 'scroll' will move the contents
            of the Marquee in the direction specified by the direction
            while 'alternate' will alternate between the two possible values: 
            'left' and 'right' or 
            'up' and 'down'.
          </p>
        </dd>

        <dt>
          name
        </dt>
        <dd>
          <p>readonly String - Name of the global variable created
            during construction which holds a reference to the newly created 
            xbMarquee object. This is used internally in during the animation using
            the setTimeout function.
          </p>
        </dd>

        <dt>
          runId
        </dt>
        <dd>
          <p>readonly Number - Timer ID for the animation. Returned
            by setTimeout.
          </p>
        </dd>

        <dt>
          containerDiv
        </dt>
        <dd>
          <p>readonly HTMLElement - reference to the Element which
            is used to contain the Marquee. Note that the ID attribute of the element
            will be the ID attribute used in the xbMarquee constructor with the 
            string 'container' appended. This ID can be used to style the presentation
            of the container of the Marquee using CSS.
          </p>
        </dd>

        <dt>
          div
        </dt>
        <dd>
          <p>readonly HTMLElement - reference to the Element which
            is to represent the Marquee. Note that the ID attribute of the element
            will be the ID attribute used in the xbMarquee constructor. This ID
            can be used to style the contents of the Marquee using CSS.
          </p>
        </dd>

        <dt>
          styleObj
        </dt>
        <dd>
          <p>readonly Object - reference to either the the Style
            object for the Marquee.
          </p>
          <p>
            For DOM HTML and DOM CSS Compatible browsers such as Mozilla and  
            Internet Explorer this is a reference to the Marquee's
            HTMLElement's CSS style object.
            object 
          </p>
          <p>
            For Netscape Navigator 4, this is a reference to the Marquee's Layer object.
          </p>
        </dd>

        <dt>
          html
        </dt>
        <dd>
          <p>readonly String - contains Marquee HTML content.
          </p>
        </dd>

        <dt>
          isHorizontal
        </dt>
        <dd>
          <p>readonly Boolean - true if marquee orientation is
            horizontal (left,right).
          </p>
        </dd>

        <dt>
          onmouseover
        </dt>
        <dd>
          <p>Object - reference to mouseover event handler function or null 
            if none exists. This function is called as a method of the xbMarquee object
            whenever the mouse enters the marquee.
          </p>
        </dd>

        <dt>
          onmouseover
        </dt>
        <dd>
          <p>Object - reference to mouseout event handler function or null 
            if none exists. This function is called as a method of the xbMarquee object
            with the event object as argument whenever the mouse exits the marquee.
          </p>
        </dd>

        <dt>
          onclick
        </dt>
        <dd>
          <p>Object - reference to click event handler function or null 
            if none exists. This function is called as a method of the xbMarquee object
            with the event object as argument whenever the user clicks on the marquee. Not
            supported by Netscape 4.x.
          </p>
        </dd>

        <dt>
          onstart
        </dt>
        <dd>
          <p>Object - reference to start event handler function or null
            if none exists. This function is called as a method of the xbMarquee object
            with no arguments when the behavior is set to scroll and whenever the marquee 
            resets it's position to it's starting position. 
            Note that start is not fired when the start method is called.
          </p>
        </dd>

        <dt>
          onbounce
        </dt>
        <dd>
          <p>Object - reference to bounce event handler function or null 
            if none exists. This function is called as a  method of the xbMarquee object 
            with no arguments when the behavior is set to alternate and whenever the
            marquee changes direction. 
          </p>
        </dd>

    </dl>

    <h2>Methods</h2>
    <dl>

        <dt>xbMarquee(String id, String height, String width, Number scrollAmount, Number scrollDelay, String direction, String behavior, String html)</dt>
        <dd>
          <p>Constructs an instance of the xbMarquee class.</p>
          <p>
            <h3>Arguments:</h3>
            <p>
              String id - ID to be assigned to the
              marquee.
            </p>
          </p>
          <p>
            String height - height of Marquee. May include
            units such as 'px', 'em', or '%'. Note that Netscape Navigator 4 currently is not supported 
            when using units other than pixels ('px').
          </p>
          <p>
            String width - width of Marquee. May include
            units such as 'px', 'em' or '%'. Note that Netscape Navigator 4 currently is not supported
            when using units other than pixels ('px').
          </p>
          <p>
            Number scrollAmount - 
            number of pixels to shift Marquee contents.
          </p>
          <p>
            Number scrollDelay - 
            number of milliseconds to wait between each shift.
          </p>
          <p>
            String direction - 
            one of 'left', 'right',
            'up', or 'down'.
          </p>
          <p>
            String behavior - 
            one of 'scroll', or 'alternate'.
          </p>
          <p>
            <h3>Returns:</h3>
            <p>nothing</p>
          </p>
          <p>
            <h3>Support</h3>
            <p>
              Gecko/Netscape 6+, Internet Explorer 4+, and Netscape Navigator 4.
            </p>
          </p>
        </dd>

        <dt>start()</dt>
        <dd>
          <p>
            <h3>Returns:</h3>
            <p>
              Nothing
            </p>
          </p>

          <p>
            This method starts the Marquee animation. This method should be called
            in a page's onload event handler in order to make certain that all 
            positions have been initialized in the elements created during the xbMarquee's
            construction.
          </p>
        </dd>

        <dt>stop()</dt>
        <dd>
          <p>Stops the Marquee's animation.</p>
          <p>
            <h3>Arguments:</h3>
            <p>
              None
            </p>
          </p>
          <p>
            <h3>Returns:</h3>
            <p>
              Nothing
            </p>
          </p>
        </dd>

        <dt>setInnerHTML(String html)</dt>
        <dd>
          <p>Sets the xbMarquee's content.</p>
          <p>
            <h3>Arguments:</h3>
            <p>
              String html containing markup
              to be used as the new content of the xbMarquee.
            </p>
          </p>
          <p>
            <h3>Returns:</h3>
            <p>
              Nothing
            </p>
          </p>
          <p>
            <h3>Note:</h3>
            <p>
              Only supported by Gecko and Internet Explorer 5+.
            </p>
          </p>
        </dd>

    </dl>

    <h2>Examples</h2>

      <h3>Download</h3>
      <p>
        <a href="examples/xbMarquee-examples.zip">xbMarquee-examples.zip</a>
      </p>

    <p>
      These examples illustrate the variety of uses for xbMarquee. Using
      xbMarquee you can create left or right horizontal scrollers, up or down
      vertical scrollers, scrollers which react to mouseover, mouseout and click
      events as well as react to changing states, scrollers in different languages
      (left to right languages and right to left languages), scrollers which
      load content from external javascript files and scrollers which automatically
      are updated from external HTML documents whenever they are refreshed.
    </p>

    <p>
      Please view source for each example in order to understand it's 
      construction.
    </p>

    <p>
      <h3>Support for Examples</h3>
      <p>
        The best support is found in Netscape Gecko based browsers such as Netscape 6.2.3,
        Netscape 7 and CompuServe 7. Internet Explorer 5+/Windows provides good support
        while Internet Explorer 5/Macintosh
        has major limitations. 
        Netscape 4.x's has several limitations while Opera is no longer supported
        except for static display in a DIV.
        Please test the different examples in each of the browsers
        you wish to support and make your design decisions accordingly.
      </p>
    </p>

    <h3>General Examples</h3>

  <h4><a href="examples/tests.html">Tests in Quirks Mode</a></h4>
    <p>
      These tests illustrate the behavior of xbMarquee using
      each of the possible directions (up, down, left, right) and 
      each possible behavior (scroll, alternate). Use these tests
      to test how well a particular browser supports the basics of
      xbMarquee.
    </p>

    <h4><a href="examples/tests-css1compat.html">Tests in Standards Mode</a></h4>
    <p>
      These tests illustrate the behavior of xbMarquee using
      each of the possible directions (up, down, left, right) and 
      each possible behavior (scroll, alternate). Use these tests
      to test how well a particular browser supports the basics of
      xbMarquee.
    </p>

    <h4><a href="examples/en-basic.html">Basic Example</a></h4>
    <p>
      Illustrates the basics of using xbMarquee. 
    </p>

    <h4><a href="examples/en-events.html">Using Event Handlers</a></h4>

    <h4><a href="examples/en-style.html">Using CSS to Style xbMarquee</a></h4>

    <h4><a href="examples/en-percent.html">Using Percentages in Height and Widths</a></h4>

    <h4><a href="examples/en-combined.html">Combine Multiple Marquees into single page</a></h4>

    <h4><a href="examples/en-combined-iframe.html">Marquees in IFRAME/ILAYERs</a></h4>

    <h4><a href="examples/en-set-html.html">Dynamic Content in xbMarquee.</a></h4>

    <p>
      Note that this example is only supported by Gecko/All Platforms
      and Internet Explorer 5.5/Windows.
    </p>

    <h4><a href="examples/en-js-loader.html">Load xbMarquee content from an external Javascript file.</a></h4>

    <h4>
      <a href="examples/en-document-loader.html">Automatic refreshing of xbMarquee content from an external file
        without reloading page.
      </a>
    </h4>

    <h4>
      <a href="examples/en-rtl.html">
        Using CSS direction: rtl; 
      </a>
    </h4>
    <p>
      xbMarquee using BIDI CSS direction:rtl; for use in right to left languages
      such as Hebrew and Arabic. 
    </p>
    <p>
      Gecko based browsers are the only ones which currently
      support using right to left direction via CSS combined with positioning.
    </p>

    <h3>Chinese Examples</h3>

      <h4>
        <a href="examples/ch-basic.html">
          Simplified Chinese Example
        </a>
    </h4>
      <p>
        Basic xbMarquee.
      </p>

      <h4>
        <a href="examples/ch-js-loader.html">
          Simplified Chinese Example loading JavaScript Data
        </a>
      </h4>
      <p>
        xbMarquee which loads content from an external JavaScript file.
      </p>

      <h4>
        <a href="examples/ch-pauser.html">
          Simplified Chinese Example with Pausing
      </a>
      </h4>
      <p>
        xbMarquee which scrolls a table of links vertically
        with Mouse Over pausing.
      </p>


    <h3>Hebrew Examples</h3>

      <h4>
        <a href="examples/he-basic.html">
          Basic Example
        </a>
      </h4>


 </nde:content>

<nde:related area="nde">
  <nde:item url="/toolbox/examples/2002/xb/">More xbAPI Examples</nde:item>
</nde:related>

</nde:article>
