spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column13


Assigning the Messages

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

The banner displays a set of messages by rotating them in a predetermined order. We'll use an array to specify the HTML code for each message. Note that a message may consist of plain text, links, images, or any other valid code. We recommend text-based messages, including hypertext links, because text loads much faster than images.

All messages should have a similar format. We'll use one-line text messages to demonstrate. Here's the definition of the array:

var ar = new Array(
  '<A HREF="/js/column1/">Universal JavaScript Rollovers</A> - <I>Rx #1</I>',
  '<A HREF="/js/column2/">Mastering JavaScript Dates</A> - <I>Rx #2</I>',
  '<A HREF="/js/column3/">Rotating Text Banners</A> - <I>Rx #3</I>',
  '<A HREF="/js/column4/">Text Rollovers</A> - <I>Rx #4</I>',
  '<A HREF="/js/column5/">Regular Expressions</A> - <I>Rx #5</I>',
  '<A HREF="/js/column6/">Browser Compatibility</A> - <I>Rx #6</I>',
  '<A HREF="/js/column7/">Window Spawning and Remotes</A> - <I>Rx #7</I>',
  '<A HREF="/js/column8/">Crispy JavaScript Cookies</A> - <I>Rx #8</I>',
  '<A HREF="/js/column9/">The Navigator Event Model</A> - <I>Rx #9</I>',
  '<A HREF="/js/column10/">The Internet Explorer Event Model</A> - <I>Rx #10</I>',
  '<A HREF="/js/column11/">The Cross-Browser Event Model</A> - <I>Rx #11</I>',
  '<A HREF="/js/column12/">JavaScript Selections</A> - <I>Rx #12</I>'
);

As you can see, each array element is a string containing the HTML code necessary for the message. Any HTML definitions can be included in the messages.

The messages are assigned to the array's elements when the array is created. When you specify LANGUAGE="JavaScript1.2" in the <SCRIPT> tag, the Array() constructor assigns its arguments to the new array's elements. In Navigator 3.0x, for example, the Array() constructor accepts one argument, which specifies the length of the array. The Array() function in Internet Explorer 4.0x, as in Navigator 4.0x, creates the new array and then assigns its arguments to the array's elements. The script's LANGUAGE="JavaScript1.2" attribute ensures that only Navigator 4.0x and Internet Explorer 4.0x execute the script, so the array is properly defined. The next section of the column lists the entire code for the bannerconfig.js file.

http://www.internet.com

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business


Created: February 10, 1998
Revised: February 10, 1998

URL: http://www.webreference.com/js/column13/array.html