JavaScript Programmer’s Reference This keyword also represents a (Web hosting reviews)

JavaScript Programmer’s Reference This keyword also represents a Java data type and the char keyword allows for the potential extension of JavaScript interfaces to access Java applet parameters and return values. byte, java.lang.Character, LiveConnect, Reserved word See also: Cross-references: ECMA 262 edition 2 section 7.4.3 ECMA 262 edition 3 section 7.5.2 Character constant (Definition) A literal description of a single character. String primitive Property/method value type: A character constant in JavaScript is represented by a single character length String primitive. Technically it is a string, not a character. In JavaScript the single quote delimiter encloses strings as well as the double quote delimiter. Beware of this if you are familiar with C language character constants. In C, the single quote (apostrophe) is used to enclose a single character that can be represented by a byte. Some character constant escape codes are listed in the following table: Escape Sequence: Name: Symbol: ” Double Quote ” ‘ Single Quote (Apostrophe) ‘ \ Backslash a Audible alert (MSIE displays the letter a) b Backspace (ignored silently in MSIE) f Form Feed (ignored silently in MSIE) n Line Feed (Newline - MSIE inserts a space) r Carriage Return (MSIE inserts a space) t Horizontal Tab (MSIE inserts a space) v Vertical tab (MSIE displays the letter v) nn Octal escape - 42 Double Quote ” 47 Single Quote (Apostrophe) ‘ 134 Backslash xnn Hexadecimal escape - Table continued on following page #BREAK# C Character display semantics (Definition) Escape Sequence: Name: Symbol: x22 Double Quote ” x27 Single Quote (Apostrophe) ‘ x5C Backslash unnnn Unicode escape - u0022 Double Quote ” u0027 Single Quote (Apostrophe) ‘ u005C Backslash uFFFE A special Unicode sentinel character for flagging byte reversed text - uFFFF A special Unicode sentinel character - See also: Character handling, Constant, Constant expression, Escape sequence (), Literal, Primitive value Character display semantics (Definition) How characters are displayed on the implementation’s console. Although the standard defines many escape sequences (see table), how these are displayed depends very much on the way that the implementation uses the output of JavaScript: Escape Sequence: Name: Symbol: ” Double Quote ” ‘ Single Quote (Apostrophe) ‘ \ Backslash a Audible alert (MSIE displays the letter a) b Backspace (ignored silently in MSIE) f Form Feed (ignored silently in MSIE) n Line Feed (Newline - MSIE inserts a space) r Carriage Return (MSIE inserts a space) t Horizontal Tab (MSIE inserts a space) v Vertical tab (MSIE displays the letter v) nn Octal escape - 42 Double Quote ” 47 Single Quote (Apostrophe) ‘ 134 Backslash xnn Hexadecimal escape - x22 Double Quote ” x27 Single Quote (Apostrophe) ‘ Table continued on following page #BREAK# JavaScript Programmer’s Reference Escape Sequence: Name: Symbol: x5C Backslash unnnn Unicode escape - u0022 Double Quote ” u0027 Single Quote (Apostrophe) ‘ u005C Backslash uFFFE A special Unicode sentinel character for flagging byte-reversed text - uFFFF A special Unicode sentinel character - Encoding line feeds, form feeds, and tabs into data that ultimately gets output as part of a document.write() method suggests that the target is an HTML page. When HTML is rendered, any embedded tabs and line terminators have no effect at all on the displayed output apart from some undesirable side effects in older browsers, which used to display line terminators inside anchor tags in a very odd way. On the other hand, JavaScript that is generating a text data stream that is going to be returned via a TCP socket may well want to encode all kinds of escaped control characters. Warnings: . Generally a browser will ignore any escape sequences it cannot cope with. Some it will ignore silently such as a bwhich results in no output in the MSIE browser. For others, such as a, MSIE ignores the backslash but writes the letter ‘a’ into the document output. A few escape characters result in a space character being inserted into the output text. . You should, as a matter of course, clean your HTML text of any unwanted escape characters if you can. Character set, Environment, Escape sequence () See also: Character entity (Definition) A means of escaping difficult-to-type characters for use in HTML. Refer to: HTML Character entity Character handling (Advice) Functions for testing character attributes. Developers who use the C language and who are converting to JavaScript may be used to having support for testing various properties of character codes. These functions are not formally part of the JavaScript language, although some of them are provided as part of the host environment through additional objects that provide C-like functionality. These are modeled on the Math object and cannot usually be instantiated by belonging to the Global object in the same way as the Math object does. #BREAK# C Character set (Definition) ScriptEase by Nombas is one interpreter that provides support for C language functionality through its Clib object. If you are using other interpreters, you can simulate these character handling functions with fragments of script and some bitwise operators. The following functions that are normally available to C programmers are simulated with the script examples in the following sections: . isalnum() . isalpha() . iscntrl() . isdigit() . isgraph() . islower() . isprint() . ispunct() . isspace() . isupper() . isxdigit() See also: isAlnum(), isAlpha(), isCtrl(), isDigit(), isGraph(), isLower(), isODigit(), isPrint(), isPunct(), isSpace(), isUpper(), isXDigit() Character set (Definition) The collection of characters that the script can operate on. Since JavaScript 1.3 and JScript 3.0, the language has been built around the Unicode standard. This means its identifiers and hence its script source code is intended to be represented by a sequence of Unicode characters. The benefit of this is that identifiers can be named using international characters. The reality is that some implementations don’t support this very well, even if they can parse and process Unicode correctly as data. As is the case with many languages, there may be a character set that can be used for data and a smaller sub-set that is valid for use when editing script source text. Strictly speaking, a JavaScript script source can be encoded with 7 bit ASCII characters since there are mechanisms to escape generated character codes that are multi-byte Unicode code points. The Unicode standard describes a large number of international character sets in terms of the character glyphs supported by them. There are also a large number of ISO standardized character sets. See also: ASCII, Character display semantics, Character handling, Character-case mapping, Environment, Escape sequence (), isLower(), isUpper(), Locale-specific behavior, Localization, Multi-byte character, Unicode #BREAK# JavaScript Programmer’s Reference Character testing (Definition) Testing characters for attributes. The following functions that are normally available to C programmers are simulated with script examples in the following sections: . isalnum() . isalpha() . iscntrl() . isdigit() . isgraph() . islower() . isprint() . ispunct() . isspace() . isupper() . isxdigit() Strictly speaking, these functions should be coded to be aware of locale-specific issues. You may want to take example simulations provided here and modify them to your own needs to support that. These are just basic working examples. Character handling, Character-case mapping, isAlnum(), isAlpha(), isCtrl(), isDigit(), isGraph(), isLower(), isODigit(), isPrint(), isPunct(), isSpace(), isUpper(), isXDigit(), String.charAt(), String.charCodeAt(), String.fromCharCode() See also: Character value (Definition) A numeric value based on the Unicode and ASCII character code points. ASCII, Integer constant, Unicode See also: Character-case mapping (Overview) Character case conversion. The conversion of characters from upper to lower case and vice versa is accomplished in JavaScript by means of the String object. This provides two methods that can be applied to a String object to change its case. However, this would not work on String primitives so you may need to do an object conversion first. #BREAK# C CharacterData object (Object/DOM) The ECMAScript standard mandates that only the base characters need be mapped between the upper and lower case. Sorting and case conversion may support other international characters in some implementations, but this is not covered by the standard. Localization issues may affect this sort of operation. The interpreter should automatically convert any String primitives to String objects so that the method can be applied. This means that this should work: “aaaa”.toUpperCase() And you should not need to do this: String(”aaaa”).toUpperCase() See also: ASCII, Character handling, Character set, Character testing, isLower(), isUpper(), Locale-specific behavior, String.charCodeAt(), String.fromCharCode(), String.toLocaleLowerCase(), String.toLocaleUpperCase(), String.toLowerCase(), String.toUpperCase(), Unicode CharacterData object (Object/DOM) A sub-class of the nodeobject with extensions to support access to character data within the object. Availability: DOM level 1 JavaScript 1.5 JScript 5.0 Internet Explorer 5.0 Netscape 6.0 Inherits from: Node object JavaScript syntax: -myCharacterData = new CharacterData() Object properties: data, length Object methods: appendData(), deleteData(), insertData(), replaceData(), substringData() COMMENT object See also: Property JavaScript JScript N IE Opera DOM Notes data 1.5 + 5.0 + 6.0 + 5.0 + 1 + - length 1.5 + 5.0 + 6.0 + 5.0 + 1 + - Method JavaScript JScript N IE Opera DOM Notes appendData() 1.5 + 5.0 + 6.0 + 5.0 + 1 + - deleteData() 1.5 + 5.0 + 6.0 + 5.0 + 1 + - insertData() 1.5 + 5.0 + 6.0 + 5.0 + 1 + - replaceData() 1.5 + 5.0 + 6.0 + 5.0 + 1 + - substringData() 1.5 + 5.0 + 6.0 + 5.0 + 1 + - #BREAK# JavaScript Programmer’s Reference Inheritance chain: Node object CharacterData.appendData() (Method) Append some text to the end of the character data. Availability: DOM level 1 JavaScript 1.5 JScript 5.0 Internet Explorer 5.0 Netscape 6.0 JavaScript syntax: -myCharacterData.appendData(aString) Argument list: aString Some data to append CharacterData.data (Property) The current contents of the character data node. Availability: DOM level 1 JavaScript 1.5 JScript 5.0 Internet Explorer 5.0 Netscape 6.0 Property/method value type: String primitive JavaScript syntax: -myCharacterData.data CharacterData.deleteData() (Method) Remove a section of text from the data contained in the character data node. Availability: DOM level 1 JavaScript 1.5 JScript 5.0 Internet Explorer 5.0 Netscape 6.0 JavaScript syntax: -myCharacterData.deleteData(anOffset, aCount) anOffset The start of the deleted section Argument list: aCount The length of the deleted section #BREAK# C CharacterData.insertData() (Method) CharacterData.insertData() (Method) Insert some additional text into the character data node. Availability: DOM level 1 JavaScript 1.5 JScript 5.0 Internet Explorer 5.0 Netscape 6.0 JavaScript syntax: -myCharacterData.insertData(anOffset, aString) anOffset A location to insert the data at Argument list: aString The data to insert CharacterData.length (Property) Return the length (in characters) of the character data node. Availability: DOM level 1 JavaScript 1.5 JScript 5.0 Internet Explorer 5.0 Netscape 6.0 Property/method value type: Number primitive JavaScript syntax: -myCharacterData.length CharacterData.replaceData() (Method) Replace a section of text in the character data node with some new text. Availability: DOM level 1 JavaScript 1.5 JScript 5.0 Internet Explorer 5.0 Netscape 6.0 JavaScript syntax: -myCharacterData.replaceData(anOffset, aCount, aString) anOffset The location where the replacement starts aCount The length of data to be replaced Argument list: aString The new data to insert #BREAK# JavaScript Programmer’s Reference CharacterData.substringData() (Method) Availability: Property/method value type: JavaScript syntax: Argument list: Checkbox object (Object/DOM) A checkbox to be used in a form. It toggles as it is clicked, but is not related to other checkboxes in the way that radio buttons are related to one another in families. Non destructively extract a section of the text from the character data node. DOM level 1 JavaScript 1.5 JScript 5.0 Internet Explorer 5.0 Netscape 6.0 String primitive -myCharacterData.substringData(anOffset, aCount) anOffset A location where the substring starts aCount The length of the substring Availability: DOM level 1 JavaScript 1.0 JScript 1.0 Internet Explorer 3.02 Netscape 2.0 Opera 3.0 Inherits from: Input object -myCheckbox = myDocument.aFormName.anElementName -myCheckbox = myDocument.aFormName.elements[anItemIndex] IE myCheckbox = myDocument.all.anElementID IE myCheckbox = myDocument.all.tags(”INPUT”)[anIndex] IE myCheckbox = myDocument.all[aName] -myCheckbox = myDocument.forms[aFormIndex].anElementName -myCheckbox = myDocument.forms[aFormIndex].elements [anItemIndex] -myCheckbox = myDocument.getElementById(anElementID) -myCheckbox = myDocument.getElementsByName(aName)[anIndex] JavaScript syntax: -myCheckbox = myDocument.getElementsByTagName(”INPUT”) [anIndex] #BREAK# C Checkbox object (Object/DOM) HTML syntax: anIndex A valid reference to an item in the collection aName The nameattribute of an element anElementID The ID attribute of an element anItemIndex A valid reference to an item in the collection Argument list: aFormIndex A reference to a particular form in the forms collection Object properties: checked, defaultChecked, indeterminate, status, type, value Object methods: handleEvent() Event handlers: onAfterUpdate, onBeforeUpdate, onBlur, onClick, onDblClick, onErrorUpdate, onFilterChange, onFocus, onHelp, onKeyDown, onKeyPress, onKeyUp, onMouseDown, onMouseMove, onMouseOut, onMouseOver, onMouseUp, onRowEnter, onRowExit Many properties, methods, and event handlers are inherited from the Input object class. Refer to topics grouped with the “Input” prefix for details of common functionality across all sub-classes of the Input object super-class. There isn’t really a Checkboxobject class but it is helpful when trying to understand the wide variety of input element types if we can reduce the complexity by discussing only the properties and methods of a checkbox. In actual fact, the object is represented as an item of the Input object class. Checkboxes may be used in groups where each one has the same name. However, this breaks the mechanism by which a form element can be accessed associatively since there is now more than one object with the same name. The fix for this is to support an InputArray so that you can access the items with the same name from a collection. Although Checkbox items should not deactivate other items in the same family in the way that Radio buttons do, you can relate their states to one another by means of the onclick event handler. Unlike MSIE, Netscape does not support the defaultValue property or the select() method for this sub-class of the Input object. Warnings: . If you enumerate a formobject that has several elements having the same name, in Netscape these will be represented by a single property of that name that refers to an InputArray. In MSIE, you will get multiple properties with the same name, but each will refer to a collection object. This is probably a bug in MSIE, which exhibits this behavior in version 5 for Macintosh and probably on other platforms too. . Note that on MSIE, Inputobjects are actually INPUT objects because MSIE follows a general rule of naming object classes after the capitalised name of the HTML tag that instantiates them. #BREAK# JavaScript Programmer’s Reference Example code:

?
Selection A
Selection B
Selection C
Selection D
See also: Element object, Form.elements[], FormElement object, Input object, Input.accessKey, onClick Property JavaScript JScript N IE Opera DOM HTML Notes checked 1.0 + 1.0 + 2.0 + 3.02 + 3.0 + 1 + - defaultChecked 1.0 + 1.0 + 2.0 + 3.02 + 3.0 + 1 + - indeterminate 3.0 + 4.0 + - status 3.0 + 4.0 + Warning type 1.1 + 1.0 + 3.0 + 3.02 + 3.0 + 1 + -ReadOnly value 1.0 + 1.0 + 2.0 + 3.02 + 3.0 + 1 + Warning Method JavaScript JScript N IE Opera DOM HTML Notes handleEvent() 1.2 + 4.0 + - Event name JavaScript JScript N IE Opera DOM HTML Notes onAfterUpdate 3.0 + 4.0 + - onBeforeUpdate 3.0 + 4.0 + - onBlur 1.1 + 3.0 + 3.0 + 4.0 + 3.0 + Warning onClick 1.0 + 3.0 + 2.0 + 4.0 + 3.0 + 4.0 + Warning onDblClick 1.2 + 3.0 + 4.0 + 4.0 + 3.0 + 4.0 + Warning #BREAK# C Checkbox.checked (Property) Event name JavaScript JScript N IE Opera DOM HTML Notes onErrorUpdate 3.0 + 4.0 + - onFilterChange 3.0 + 4.0 + - onFocus 1.0 + 3.0 + 2.0 + 4.0 + 3.0 + Warning onHelp 3.0 + 4.0 + Warning onKeyDown 1.2 + 3.0 + 4.0 + 4.0 + 3.0 + 4.0 + Warning onKeyPress 1.2 + 3.0 + 4.0 + 4.0 + 3.0 + 4.0 + Warning onKeyUp 1.2 + 3.0 + 4.0 + 4.0 + 3.0 + 4.0 + Warning onMouseDown 1.2 + 3.0 + 4.0 + 4.0 + 3.0 + 4.0 + Warning onMouseMove 1.2 + 3.0 + 4.0 + 4.0 + 4.0 + Warning onMouseOut 1.1 + 3.0 + 3.0 + 4.0 + 3.0 + 4.0 + Warning onMouseOver 1.0 + 3.0 + 2.0 + 4.0 + 3.0 + 4.0 + Warning onMouseUp 1.2 + 3.0 + 4.0 + 4.0 + 3.0 + 4.0 + Warning onRowEnter 3.0 + 4.0 + - onRowExit 3.0 + 4.0 + - Inheritance chain: Element object, Input object, Node object Checkbox.checked (Property) The state of the checkbox is maintained in this property. Availability: DOM level 1 JavaScript 1.0 JScript 1.0 Internet Explorer 3.02 Netscape 2.0 Opera 3.0 Property/method value type: Boolean primitive JavaScript syntax: -myCheckbox.checked HTML syntax: If the checkbox has a mark in it (depending on the UI display appearance guidelines, this may be a tick or a cross), then this value will return true. Otherwise it will return false. #BREAK# JavaScript Programmer’s Reference Checkbox.defaultChecked (Property) The original initial default state of a checkbox. Availability: DOM level 1 JavaScript 1.0 JScript 1.0 Internet Explorer 3.02 Netscape 2.0 Opera 3.0 Property/method value type: Boolean primitive JavaScript syntax: -myCheckbox.defaultChecked HTML syntax: The defaultCheckedstate of an Input item is the value that was defined in the HTML document source when the page was loaded. You can use this value if you need to reset the status of a page or determine whether the user has changed the settings on an input item since the page was loaded. Checkbox.handleEvent() (Method) Pass an event to the appropriate handler for this object. Availability: JavaScript 1.2 Netscape 4.0 Property/method value type: undefined JavaScript syntax: N myResetButton.handleEvent(anEvent) Argument list: anEvent An event to be handled by this object This applies to Netscape prior to version 6.0. From that release onwards, event management follows the guidelines in the DOM level 3 event specification. On receipt of a call to this method, the receiving object will look at its available set of event-handler functions and pass the event to an appropriately mapped handler function. It is essentially an event dispatcher that is granular down to the object level. The argument value is an Eventobject that contains information about the event. handleEvent() See also: #BREAK# C Checkbox.indeterminate (Property) Checkbox.indeterminate (Property) A checkbox is in this state if it was selected, but then disabled. The state cannot be accurately and unambiguously determined. Availability: JScript 3.0 Internet Explorer 4.0 Property/method value type: Boolean primitive JavaScript syntax: IE myCheckbox.indeterminate Checkboxes may be enabled and disabled. If you have a checkbox that was enabled and then checked, and then if it is subsequently disabled, this flag property is set to true which indicates that the current state of the checkbox is indeterminate. Checkbox.status (Property) The current highlighted or checked status of the input element. Availability: JScript 3.0 Internet Explorer 4.0 Property/method value type: Boolean primitive JavaScript syntax: IE myCheckbox.status This is the current status of the checkbox item. It is either checked or not. If the checkbox has not been changed since the page was loaded from the server, then this value will be the same as the defaultChecked property of the checkbox. Warnings: . Because this is not supported on all browsers, you should use the Checkbox.checked property instead if portable code is important to your project. Checkbox.type (Property) The type value for the tag that describes the form checkbox. DOM level 1 JavaScript 1.1 JScript 1.0 Internet Explorer 3.02 Netscape 3.0 Opera 3.0 String primitive Availability: Property/method value type: #BREAK# JavaScript Programmer’s Reference JavaScript syntax: -myCheckbox.type HTML syntax: The typevalue for a checkbox is always “checkbox”. This value is necessary to determine the type of form element because this object is really an instance of the Input class and not the Checkbox class. There is actually no Checkbox class. Input.type See also: Property attributes: ReadOnly. Checkbox.value (Property) The text string for this particular checkbox object. Availability: DOM level 1 JavaScript 1.0 JScript 1.0 Internet Explorer 3.02 Netscape 2.0 Opera 3.0 Property/method value type: String primitive JavaScript syntax: -myCheckbox.value HTML syntax: This value is returned to the server during a submit only if the checked state for this radio button is on. Warnings: . If the checkbox is used in a group or even if it isn’t, the state of the checkbox is in the checked property not the value property. See also: Input.value CheckerBoard() (Filter/transition) A transition effect with the appearance of chequer board blinds opening or closing. Availability: JScript - 5.5 Internet Explorer - 5.5 Refer to: filter -CheckerBoard() #BREAK# C ChildNodes object (Object/DOM) ChildNodes object (Object/DOM) A collection of all the children belonging to a DOM Node object. Availability: DOM level 1 JavaScript 1.5 JScript 5.0 Internet Explorer 5.0 Netscape 6.0 JavaScript syntax: -myChildNodes = myElement.childNodes This is part of the internal DOM hierarchy model in the browser. There are several tree hierarchies supported and this one maintains a tree of parent-child node relationships across the document. Element object, Element.childNodes[], Hierarchy of objects See also: Chroma() (Filter/visual) A visual filter for chroma key effects. Availability: JScript 3.0 Internet Explorer 4.0 Refer to: Filter - Chroma() CITE object (Object/HTML) An object representing the HTML content delimited by the HTML tags. Availability: JScript 3.0 Internet Explorer 4.0 Inherits from: Element object IE myCITE = myDocument.all.anElementID IE myCITE = myDocument.all.tags(”CITE”)[anIndex] IE myCITE = myDocument.all[aName] -myCITE = myDocument.getElementById(anElementID) -myCITE = myDocument.getElementsByName(aName)[anIndex] JavaScript syntax: -myCITE = myDocument.getElementsByTagName(”CITE”)[anIndex] HTML syntax: anElementID The ID value of the element required anIndex A valid reference to an item in the collection Argument list: aName The nameattribute of an element #BREAK# JavaScript Programmer’s Reference onClick, onDblClick, onDragStart, onFilterChange, onHelp, onKeyDown, onKeyPress, onKeyUp, onMouseDown, onMouseMove, onMouseOut, onMouseOver, onMouseUp, onSelectStart Event handlers: Event name JavaScript JScript N IE Opera DOM HTML Notes onClick -3.0 + -4.0 + 3.0 + 4.0 + Warning onDblClick -3.0 + -4.0 + 3.0 + 4.0 + Warning onDragStart 3.0 + 4.0 + - onFilterChange 3.0 + 4.0 + - onHelp 3.0 + 4.0 + Warning onKeyDown -3.0 + -4.0 + 3.0 + 4.0 + Warning onKeyPress -3.0 + -4.0 + 3.0 + 4.0 + Warning onKeyUp -3.0 + -4.0 + 3.0 + 4.0 + Warning onMouseDown -3.0 + -4.0 + 3.0 + 4.0 + Warning onMouseMove -3.0 + -4.0 + 4.0 + Warning onMouseOut -3.0 + -4.0 + 3.0 + 4.0 + Warning onMouseOver -3.0 + -4.0 + 3.0 + 4.0 + Warning onMouseUp -3.0 + -4.0 + 3.0 + 4.0 + Warning onSelectStart 3.0 + 4.0 + - Inheritance chain: Element object, Node object Refer to: Element object Class (Property/internal) Internal property that returns an object class. ECMAScript edition 2 Availability: This internal property returns a string value containing the class name of the containing object. Every object type must implement this property. It is supported by all built-in native objects in an ECMA-compliant JavaScript interpreter. Host objects may supply any value as a Class identifying string. They may even masquerade as one of the built-in classes, but good sense suggests that if they do, then they must obey the protocol of that built-in class in precisely the same way as if they were a real built-in object. It’s probably sensible for host implementers to avoid overloading the built-in class names like that. #BREAK# C class (Reserved word) At edition 2 of the ECMA standard, there is no publicly accessible method to retrieve this property in a script. However, the reserved keyword values suggest that this may be offered at a later revision of the standard. See also: Array.Class, Boolean.Class, class, Date.Class, Function.Class, Internal Property, Number.Class, Object.Class, Reserved word, String.Class Property attributes: Internal. Cross-references: ECMA 262 edition 2 section 8.6.2 ECMA 262 edition 3 section 8.6.2 class (Reserved word) Reserved for future language enhancements. Although you cannot request the class of a particular object, you can probably establish what class it belongs to with the typeof operator. This keyword also represents a Java object type and the class keyword allows for the potential extension of JavaScript interfaces to access Java applet parameters and return values. See also: Class, Internal Property, java.lang.Class, LiveConnect, Reserved word, typeof Cross-references: ECMA 262 edition 2 section 7.4.3 ECMA 262 edition 2 section 11.4.3 ECMA 262 edition 3 section 7.5.3 ECMA 262 edition 3 section 11.4.3 Class method (Definition) Methods owned by a constructor function object. Refer to: Static method #BREAK# JavaScript Programmer’s Reference Class variable (Definition) Static variables owned by a constructor function object. Property See also: Refer to: Static variable CLASS=”…” (HTML Tag Attribute) A means of associating a tag with a stylesheet class. Represented by the className property of an Element object. DOM level 1 JavaScript 1.5 JScript 3.0 Internet Explorer 4.0 Netscape 6.0 Availability: In MSIE, virtually any object can be associated with a style object by means of the CLASS attribute. This is reflected into the className property of the object. It is especially applicable to DOM-related objects, which are considered to be sub-classed from the Element object. Netscape 6.0 brings that browser into line with these capabilities. See also: DOM, Element object, Element.className, Element.style, STYLE object (1), style object (2) classes (Property) An alternative reference to the document.classes property in JSS. JavaScript 1.2 Netscape 4.0 Deprecated Netscape 6.0 Collection object classes N Availability: Property/method value type: JavaScript syntax: N myDocument.classes Warnings: .This functionality is removed from Netscape 6.0. See also: JavaScript Style Sheets, Document.classes[] #BREAK# C CLASSPATH (Environment variable) CLASSPATH (Environment variable) This is an important environment variable that helps Java code locate resources on your system. It needs to be set correctly. Java, LiveConnect See also: clearInterval() (Method) Cancel a previous setInterval() timer. myWindow.clearInterval(anIntervalID) - The ID of an interval returned by the anIntervalID Argument list: setInterval() method Availability: JavaScript 1.2 JScript 3.0 Internet Explorer 4.0 Netscape 4.0 Property/method value type: undefined -clearInterval(anIntervalID)JavaScript syntax: See also: Window.clearTimeout(), Window.clearInterval() clearTimeout() (Method) A function that removes a pending timeout event. myWindow.clearTimeout(aTimeoutID) - The ID of a timeout returned by the aTimeoutID Argument list: setTimeout() method Availability: JavaScript 1.0 JScript 1.0 Internet Explorer 3.02 Netscape 2.0 Opera 3.0 Property/method value type: undefined -clearTimeout(aTimeoutID)JavaScript syntax: #BREAK# JavaScript Programmer’s Reference Warnings: . This can cause problems if the timeout event you have identified has already been executed. Pending timeouts quite reasonably can be removed. Already executed timeout actions cannot be removed and may crash the browser if you try to remove them. Be sure that you are really removing a pending timeout. . A better technique is to set flags in global variables and use them to inhibit the creation of a new timeout event if you are using this for a kind of interval timer. See also: Window.clearTimeout(), Window.setTimeout() client object (Object/NES) A server-side object available in NES. client Availability: JavaScript 1.1 Netscape Enterprise Server 2.0 JavaScript syntax: NES client HTML syntax: Object methods: destroy(), expiration() One client object is created for each browser user. It is created when the user first accesses the NES application and persists until some time after they have last visited. A timeout allows the server to garbage-collect these sessionobjects and purge them out. If a client comes back again later, a new object will need to be created. Because there is no sessionobject in Netscape Enterprise Server, this object serves the purpose of maintaining session state as well as holding details of the client. To maintain state across all session in an application, you should use the project object discussed in a separate topic. Client objects have a limited lifetime. It is configurable but typically they will expire and be discarded after 10 minutes of inactivity. See also: Netscape Enterprise Server, project object, response.client, unwatch(), watch() Method JavaScript JScript NES Notes destroy() 1.1 + 2.0 + - expiration() 1.1 + 2.0 + - #BREAK# C client.destroy() (Method) client.destroy() (Method) This destroys the client object. Availability: JavaScript 1.1 Netscape Enterprise Server 2.0 JavaScript syntax: NES client.destroy() Calling this method on a client object will remove it and if the user makes another request, a new client object will have to be created. This is slightly inconsistent with the normal way that objects are destroyed. Normally the delete operator would be used. client.expiration() (Method) This method will define the timeout after which the client object will expire. Used to set the life-span of a client object in an NES server. Availability: JavaScript 1.1 Netscape Enterprise Server 2.0 JavaScript syntax: NES client.expiration(aTime) Argument list: aTime A time value measured in seconds This method allows the number of seconds before a session times out to be defined. After this time, the client object will be purged automatically and if the user connects again after that, a new client object will need to be created. The expiration time can be set for individual clientobjects. You may have one that needs to persist longer based on the kind of session the user is experiencing. For example, it might be useful to expire an e-commerce session quickly to prevent misuse. A content administrator may need a session to be active for a much longer time than usual. Typical expiry time for this sort of thing would be about 30 minutes. This is in line with current practice of log analysis techniques and log auditing. Breaks of more than 30 minutes are considered to be multiple sessions. Client pull techniques (Definition) This is a technique whereby the client end pulls content from the server at regular intervals. Refer to: Timer events #BREAK# JavaScript Programmer’s Reference Client-side JavaScript (Definition) The JavaScript that gets executed in the web browser or other client application. See also: .jar, .java, .js, Desktop JavaScript, HTML file, Server-side JavaScript, Web browser Cross-references: Wrox Instant JavaScript page 3 Wrox Instant JavaScript page 5 clientInformation (Property) Details of the browser, A.K.A. the navigator object. Availability: JScript 3.0 Internet Explorer 4.0 Property/method value type: Navigator object IE clientInformation JavaScript syntax: IE myWindow.clientInformation See also: Cross platform compatibility, Navigator object, Window.clientInformation, Window.navigator Property attributes: ReadOnly, DontEnum. Clip object (Object/Navigator) An object that represents a clip region within a layer. JavaScript 1.2 Netscape 4.0 Deprecated Netscape 6.0 Availability: N myClip = myLayer.clip N myClip = myStyle.clip N myClip = myTextRectangle JavaScript syntax: N myClip = myRect Object properties: bottom, height, left, right, top, width #BREAK# C Clip.bottom (Property) This object represents a clipping rectangle that the visible part of a display object is viewed through. This is most likely used with a layer object. The layer contents would be drawn off-screen and then that part that falls within the clipping rectangle would be displayed in the window. This can be useful for performing wipes and making parts of a layer progressively visible within some kind of transition loop. In the MSIE browser, these rectangular objects are manufactured as needed with the rect() constructor function. Warnings: . No longer supported in Netscape 6.0. See also: Layer.clip, Rect object, style.clip, textRectangle object Property JavaScript JScript N IE Opera Notes bottom 1.2 + 4.0 + Warning, Deprecated height 1.2 + 4.0 + Warning, Deprecated left 1.2 + 4.0 + Warning, Deprecated right 1.2 + 4.0 + Warning, Deprecated top 1.2 + 4.0 + Warning, Deprecated width 1.2 + 4.0 + Warning, Deprecated Clip.bottom (Property) The bottom of a layer clip region. Availability: JavaScript 1.2 Netscape 4.0 Deprecated Netscape 6.0 Property/method value type: Number primitive JavaScript syntax: N myClip.bottom This defines the bottom edge of the clip region. You could modify this in a loop to create a vertical downwards wipe transition effect. Warnings: . No longer supported in Netscape 6.0. Layer.clip.bottom, Rect.bottom See also: #BREAK# JavaScript Programmer’s Reference Clip.height (Property) The height of a layer clip region. JavaScript 1.2 Netscape 4.0 Deprecated Netscape 6.0 myClip.height Availability: Property/method value type: JavaScript syntax: N Number primitive The clip region is defined by an extent rectangle that surrounds the space occupied by the clip region. An extent rectangle is the smallest rectangle that completely encloses the item. This property specifies the height of that extent rectangle. Warnings: . No longer supported in Netscape 6.0. See also: Layer.clip.height, Rect.height Clip.left (Property) The left of a layer clip region. JavaScript 1.2 Netscape 4.0 Deprecated Netscape 6.0 myClip.left Availability: Property/method value type: JavaScript syntax: N Number primitive This defines the left edge of the clip region. You could modify this in a loop to create a horizontal wipe transition effect. Warnings: . No longer supported in Netscape 6.0. See also: Layer.clip.left, Rect.left Clip.right (Property) The right of a layer clip region. JavaScript 1.2 Netscape 4.0 Deprecated Netscape 6.0 Availability: #BREAK# C Clip.top (Property) Property/method value type: JavaScript syntax: myClip.right N Number primitive This defines the right edge of the clip region. You could modify this in a loop to create a horizontal wipe transition effect. Warnings: . No longer supported in Netscape 6.0. See also: Layer.clip.right, Rect.right Clip.top (Property) The top of a layer clip region. JavaScript 1.2 Netscape 4.0 Deprecated Netscape 6.0 myClip.top Availability: Property/method value type: JavaScript syntax: N Number primitive This defines the top edge of the clip region. You could modify this in a loop to create a vertical downwards wipe transition effect. Warnings: . No longer supported in Netscape 6.0. See also: Layer.clip.top, Rect.top Clip.width (Property) The width of a layer clip region. JavaScript 1.2 Netscape 4.0 Deprecated Netscape 6.0 myClip.width Availability: Property/method value type: JavaScript syntax: N Number primitive The clip region is defined by an extent rectangle that surrounds the space occupied by the clip region. An extent rectangle is that smallest rectangle that completely encloses the item. This property specifies the width of that extent rectangle. #BREAK# JavaScript Programmer’s Reference Warnings: . No longer supported in Netscape 6.0. See also: Layer.clip.width, Rect.width clipboardData (Property) A global browser variable that refers to the clipboardData object for the window. Availability: JScript 5.0 Internet Explorer 5.0 Property/method value type: clipboardData object IE clipboardData JavaScript syntax: IE myWindow.clipboardData See also: clipboardData object, Window.clipboardData clipboardData object (Object/JScript) An object that can be used with editing operations to provide script-driven access to the clipboard contents. Availability: JScript 5.0 Internet Explorer 5.0 IE myClipboardData = clipboardData JavaScript syntax: IE myClipboardData = myWindow.clipboardData Object methods: clearData(), getData(), setData() If you want to move data in and out of the clipboard on a Windows platform from within the MSIE browser, this object encapsulates the clipboard contents. Refer to the dataTransfer object for a description of the clearData(), getData(), and setData() methods that may also be used with the clipboardData object. See also: dataTransfer.clearData(), dataTransfer.getData(), Window.clipboardData Method JavaScript JScript N IE Opera Notes clearData() 5.0 + 5.0 + - etData() 5.0 + 5.0 + - setData() 5.0 + 5.0 + - #BREAK# C close() (Method) close() (Method) A function that closes the receiving window. Availability: JavaScript 1.0 JScript 1.0 Internet Explorer 3.02 Netscape 2.0 Opera 3.0 Property/method value type: undefined -close() JavaScript syntax: -myWindow.close() See also: UniversalBrowserAccess, UniversalBrowserWrite, Window.close() closed (Property) A flag indicating the window disposition. Argument list: Property attributes: ReadOnly. Refer to: Window.closed Availability: JavaScript 1.1 JScript 3.0 Internet Explorer version 4.0 Netscape Navigator version 3.0 Opera browser 3.0 Property/method value type: Boolean primitive -closed JavaScript syntax: -myWindow.closed false The window is still open true The window has been closed #BREAK# JavaScript Programmer’s Reference Closure object (Object/internal) A special kind of function object that preserves prototype inheritance and scope. Availability: JavaScript 1.2 Netscape 4.0 JavaScript syntax: N myClosure = new Closure() Object properties: __parent__, __proto__ This is a special kind of object, which maintains some contextual state information when it is created. It can behave like a function, but is a kind of function wrapper that references a function and a scope. Since it inherits everything from the Functionobject, it can behave like a function and can be called as such. Because it also stores the scope chain at the time it is manufactured, it can restore that scope chain when it is executed. See also: Lexical scoping Property JavaScript JScript N IE Opera Notes __parent__ 1.2 + 4.0 + - __proto__ 1.2 + 4.0 + - Closure() (Object/Navigator) A Closure object constructor. Availability: JavaScript 1.2 Netscape 4.0 JavaScript syntax: N new Closure(aFunction, aTarget) aFunction The declaration of a function Argument list: aTarget An object to associate the function with This constructor is used internally to create a Closure object containing the function associated with a target object. The Closure() constructor is used in Netscape 4 to create an event-handler function that can be forced to run in a scope containing a target object. #BREAK# C Closure.__parent__ (Property) Example code: document.form1.myButton.onclick = new Closure( function() { document.validated = false; }, document.form1.myButton ); See also: Constructor function, constructor property, Global object, Object constant Closure.__parent__ (Property) A reference to a scope-chain object that is preserved with the function by the Closure object. JavaScript 1.2 ScopeChain object N myClosure.__parent__ Availability: Netscape 4.0 Property/method value type: JavaScript syntax: See also: __parent__, __proto__, Lexical scoping, Closure object Closure.__proto__ (Property) A reference to a function that is encapsulated by the Closure object. JavaScript 1.2 Function object myClosure.__proto__ N Availability: Netscape 4.0 Property/method value type: JavaScript syntax: See also: __parent__, __proto__, Lexical scoping, Closure object #BREAK# JavaScript Programmer’s Reference clsid: URL (Request method) Used by MSIE to locate ActiveX controls for the tag. A special request method for loading ActiveX objects from the locally stored object repository. This provides a portable, cross-platform, installation,independent way to refer to the folder where you have installed shared ActiveXobjects on your system. It is more or less equivalent to the file:request method but without the need to specify a path to the folder. See also: OBJECT.classid, URL Code block delimiter {} (Delimiter) A delimiting token for a block of executable script source text. Availability: ECMAScript edition 2 JavaScript 1.0 JScript 1.0 Internet Explorer 3.02 Netscape 2.0 Netscape Enterprise Server 2.0 Opera 3.0 JavaScript syntax: -aLabel: { someScript } aLabel An optional identifier to name the code block Argument list: someScript Some legal JavaScript source text A block is a list of statements that form one syntactic unit enclosed in curly brace characters ( { } ). This is particularly useful in conditional execution and iterative execution. Both of those are expected to operate on a single syntactic unit. A block allows that single syntactic unit to be composed of multiple lines of source script text. Because the curly brace characters are used to delimit a block of code that comprises a list of semicolon terminated statements, you do not need to place any semi-colons after the closing curly brace. A block of code is most often used like this with a iterator or conditional test to either call the same section of code repetitively or to execute it as the result of a conditional expression returning a true value. In compiled languages, variables declared inside a block are sometimes local to that block and are garbage-collected when the block exits. The ECMA standard indicates that variables created inside a code block will be global unless that code block is the body of a function. In ECMA-compliant interpreters, a block does not instantiate a new execution context, whereas in C language it does create a new scope within which the variables exist. This means that variables created inside an ‘ifkeyword’ controlled compound statement will be function-local or globally accessible according to whether the ‘if keyword’ is in a function or global code section. #BREAK# C CODE object (Object/HTML) Braces must be used in pairs. Although the JavaScript interpreters may forgive you when you miss out some language elements, very subtle and difficult-to-diagnose errors can occur if you misplace a brace character. Modern text editors give you a lot of help when balancing pairs of braces. The associativity is left to right. Refer to the Operator Precedence topic for details of execution order. At version 1.2 of JavaScript, you can name the code block and use the labeled form of the break keyword to exit the block prematurely. See also: Associativity, else if( … ) …, if( … ) …, if( … ) … else …, Label, Operator Precedence, Punctuator Cross-references: ECMA 262 edition 2 section 12.5 ECMA 262 edition 3 section 12.1 Wrox Instant JavaScript page 18 CODE object (Object/HTML) An object representing the HTML content delimited by the HTML tags. Availability: JScript 3.0 Internet Explorer 4.0 Inherits from: Element object IE myCODE = myDocument.all.anElementID IE myCODE = myDocument.all.tags(”CODE”)[anIndex] IE myCODE = myDocument.all[aName] -myCODE = myDocument.getElementById(anElementID) -myCODE = myDocument.getElementsByName(aName)[anIndex] JavaScript syntax: -myCODE = myDocument.getElementsByTagName(”CODE”)[anIndex] HTML syntax: anElementID The ID value of the element required anIndex A valid reference to an item in the collection Argument list: aName The nameattribute of an element Event handlers: onClick, onDblClick, onDragStart, onFilterChange, onHelp, onKeyDown, onKeyPress, onKeyUp, onMouseDown, onMouseMove, onMouseOut, onMouseOver, onMouseUp, onSelectStart #BREAK# JavaScript Programmer’s Reference See also: KBD object, LISTING object Event name JavaScript JScript N IE Opera DOM HTML Notes onClick -3.0 + -4.0 + 3.0 + 4.0 + Warning onDblClick -3.0 + -4.0 + 3.0 + 4.0 + Warning onDragStart 3.0 + 4.0 + - onFilterChange 3.0 + 4.0 + - onHelp 3.0 + 4.0 + Warning onKeyDown -3.0 + -4.0 + 3.0 + 4.0 + Warning onKeyPress -3.0 + -4.0 + 3.0 + 4.0 + Warning onKeyUp -3.0 + -4.0 + 3.0 + 4.0 + Warning onMouseDown -3.0 + -4.0 + 3.0 + 4.0 + Warning onMouseMove -3.0 + -4.0 + 4.0 + Warning onMouseOut -3.0 + -4.0 + 3.0 + 4.0 + Warning onMouseOver -3.0 + -4.0 + 3.0 + 4.0 + Warning onMouseUp -3.0 + -4.0 + 3.0 + 4.0 + Warning onSelectStart 3.0 + 4.0 + - Inheritance chain: Element object, Node object Refer to: Element object Code signing (Definition) A security mechanism to allow scripts to inter-communicate. Signed scripts are allowed higher privileges to communicate with one another because the browser assumes they are more secure. See also: Security policy, Signed scripts COL object (Object/HTML) An object that represents a HTML tag. DOM level 1 JavaScript 1.5 JScript 3.0 Internet Explorer 4.0 Netscape 6.0 Availability: #BREAK# C COL object (Object/HTML) Inherits from: Element object IE myCOL = myDocument.all.anElementID IE myCOL = myDocument.all.tags(”COL”)[anIndex] IE myCOL = myDocument.all[aName] -myCOL = myDocument.getElementById(anElementID) -myCOL = myDocument.getElementsByName(aName)[anIndex] JavaScript syntax: -myCOL = myDocument.getElementsByTagName(”COL”)[anIndex] HTML syntax: … anIndex A valid reference to an item in the collection aName The nameattribute of an element Argument list: anElementID The ID attribute of an element Object properties: align, ch, chOff, span, vAlign, width Event handlers: onClick, onDblClick, onHelp, onKeyDown, onKeyPress, onKeyUp, onMouseDown, onMouseMove, onMouseOut, onMouseOver, onMouseUp This object represents the tag, which is used within constructs to provide a way of controlling an entire table column from a single definition. It is used in conjunction with a construct. The HTML 4 specification describes functionality that currently none of the widely available browsers supports properly. The DOM specification describes a HTMLTableColElement object, which is the standardized interface to this class. COLGROUP object, Element object, style.columnSpan, TABLE object, TABLE.rules, TableColElement object, TableColElement.align, TableColElement.ch, TableColElement.chOff, TableColElement.span, TableColElement.vAlign, TableColElement.width See also: Property JavaScript JScript N IE Opera DOM HTML Notes align 1.5 + 3.0 + 6.0 + 4.0 + 1 + - ch 1.5 + 6.0 + 1 + - chOff 1.5 + 6.0 + 1 + - span 1.5 + 3.0 + 6.0 + 4.0 + 1 + - vAlign 1.5 + 3.0 + 6.0 + 4.0 + 1 + - width 1.5 + 3.0 + 6.0 + 4.0 + 1 + - Event name JavaScript JScript N IE Opera DOM HTML Notes onClick 1.5 + 3.0 + 6.0 + 4.0 + 3.0 + 4.0 + Warning onDblClick 1.5 + 3.0 + 6.0 + 4.0 + 3.0 + 4.0 + Warning #BREAK# JavaScript Programmer’s Reference Event name JavaScript JScript N IE Opera DOM HTML Notes onHelp 3.0 + 4.0 + Warning onKeyDown 1.5 + 3.0 + 6.0 + 4.0 + 3.0 + 4.0 + Warning onKeyPress 1.5 + 3.0 + 6.0 + 4.0 + 3.0 + 4.0 + Warning onKeyUp 1.5 + 3.0 + 6.0 + 4.0 + 3.0 + 4.0 + Warning onMouseDown 1.5 + 3.0 + 6.0 + 4.0 + 3.0 + 4.0 + Warning onMouseMove 1.5 + 3.0 + 6.0 + 4.0 + 4.0 + Warning onMouseOut 1.5 + 3.0 + 6.0 + 4.0 + 3.0 + 4.0 + Warning onMouseOver 1.5 + 3.0 + 6.0 + 4.0 + 3.0 + 4.0 + Warning onMouseUp 1.5 + 3.0 + 6.0 + 4.0 + 3.0 + 4.0 + Warning Inheritance chain: Element object, Node object COL.align (Property) An attribute controlling the alignment of a column contained in a HTML tag. Availability: DOM level 1 JavaScript 1.5 JScript 3.0 Internet Explorer 4.0 Netscape 6.0 Property/method value type: String primitive JavaScript syntax: -myCOL.align The alignment of the COL object with respect to its containing parent object is defined in this property. The following set of alignment specifiers are available: . absbottom . absmiddle . baseline . bottom . center . char . justify . left . middle . right . texttop . top #BREAK# C COL.ch (Property) Note that not all of these are available in every browser. In particular the justify and char values are recent additions. See also: COLGROUP.align COL.ch (Property) The alignment character for cells in a column arrangement. DOM level 1 JavaScript 1.5 Netscape 6.0 Availability: Property/method value type: JavaScript syntax: String primitive myTHEAD.ch N HTML 4.0 provides for text to be arranged in neat columns within table cells without the need to create additional tables within tables. This method of alignment is selected by setting the ALIGN=”CHAR” HTML tag attribute. The CHAR HTML tag attribute is reflected in this property and is active when the CHAROFF HTML tag attribute is present. See also: COLGROUP.ch, TD.ch, TH.ch, THEAD.ch, TR.ch COL.chOff (Property) The offset of a column alignment character. DOM level 1 JavaScript 1.5 Netscape 6.0 Availability: Property/method value type: JavaScript syntax: The CHARalignment style requires that an alignment character be specified with the ch property and that an offset measured in pixels be defined as its value. The offset value can be defined with the CHAROFF HTML tag attribute. The remainder of the string is offset by this distance from the alignment character. String primitive myTHEAD.chOff N See also: COLGROUP.chOff, TD.chOff, TH.chOff, THEAD.chOff, TR.chOff 297 #BREAK# JavaScript Programmer’s Reference COL.span (Property) The number of columns that the style for this object spans. Availability: DOM level 1 JavaScript 1.5 JScript 3.0 Internet Explorer 4.0 Netscape 6.0 Property/method value type: Number primitive JavaScript syntax: -myCOL.span This corresponds to the COLSPAN attribute within a HTML tag. Availability: DOM level 1 JavaScript 1.5 JScript 3.0 Internet Explorer 4.0 Netscape 6.0 Inherits from: Element object IE myCOLGROUP = myDocument.all.anElementID IE myCOLGROUP = myDocument.all.tags(”COLGROUP”)[anIndex] IE myCOLGROUP = myDocument.all[aName] -myCOLGROUP = myDocument.getElementById(anElementID) -myCOLGROUP = myDocument.getElementsByName(aName)[anIndex] JavaScript syntax: -myCOLGROUP = myDocument.getElementsByTagName(”COLGROUP”)[anIndex] HTML syntax: … anIndex A valid reference to an item in the collection aName The nameattribute of an element Argument list: anElementID The ID attribute of an element Object properties: align, ch, chOff, span, vAlign, width Event handlers: onClick, onDblClick, onHelp, onKeyDown, onKeyPress, onKeyUp, onMouseDown, onMouseMove, onMouseOut, onMouseOver, onMouseUp #BREAK# JavaScript Programmer’s Reference The and tags correspond to objects that represent the column or group of columns within a
or table cell description. It defines how many table columns this column is to span. See also: COLGROUP.span, TD.colSpan, TH.colSpan COL.vAlign (Property) The vertical alignment of items within this column. Availability: DOM level 1 JavaScript 1.5 JScript 3.0 Internet Explorer 4.0 Netscape 6.0 Property/method value type: String primitive JavaScript syntax: -myCOL.vAlign This property controls text alignment in the vertical axis. This applies to text cells in the column group. The vAlign property may be set to these values: . baseline . bottom . middle . top See also: COLGROUP.vAlign #BREAK# C COL.width (Property) COL.width (Property) The width of each column in the column group. Availability: DOM level 1 JavaScript 1.5 JScript 3.0 Internet Explorer 4.0 Netscape 6.0 Property/method value type: Number primitive JavaScript syntax: -myCOL.width The columns within the column group are set to a width defined by this property. Changing the value will cause the page content to be re-flowed to reflect the new value. See also: COLGROUP.width COLGROUP object (Object/HTML) An object that represents the
construct. Individual columns map to the COL object and groups of columns to the COLGROUPobject. Attributes can be applied to a group of columns and overridden on an individual column basis if necessary. The DOM specification mentions an HTMLTableColElement object, which provides the functionality of this class. COL object, style.columnSpan, TABLE object, TABLE.rules, TableColElement object, TableColElement.align, TableColElement.ch, TableColElement.chOff, TableColElement.span, TableColElement.vAlign, TableColElement.width See also: Property JavaScript JScript N IE Opera DOM HTML Notes align 1.5 + 3.0 + 6.0 + 4.0 + 1 + - ch 1.5 + 6.0 + 1 + - chOff 1.5 + 6.0 + 1 + - span 1.5 + 3.0 + 6.0 + 4.0 + 1 + - vAlign 1.5 + 3.0 + 6.0 + 4.0 + 1 + - width 1.5 + 3.0 + 6.0 + 4.0 + 1 + - Event name JavaScript JScript N IE Opera DOM HTML Notes onClick 1.5 + 3.0 + 6.0 + 4.0 + 3.0 + 4.0 + Warning onDblClick 1.5 + 3.0 + 6.0 + 4.0 + 3.0 + 4.0 + Warning onHelp 3.0 + 4.0 + Warning onKeyDown 1.5 + 3.0 + 6.0 + 4.0 + 3.0 + 4.0 + Warning onKeyPress 1.5 + 3.0 + 6.0 + 4.0 + 3.0 + 4.0 + Warning onKeyUp 1.5 + 3.0 + 6.0 + 4.0 + 3.0 + 4.0 + Warning onMouseDown 1.5 + 3.0 + 6.0 + 4.0 + 3.0 + 4.0 + Warning onMouseMove 1.5 + 3.0 + 6.0 + 4.0 + 4.0 + Warning onMouseOut 1.5 + 3.0 + 6.0 + 4.0 + 3.0 + 4.0 + Warning onMouseOver 1.5 + 3.0 + 6.0 + 4.0 + 3.0 + 4.0 + Warning onMouseUp 1.5 + 3.0 + 6.0 + 4.0 + 3.0 + 4.0 + Warning Inheritance chain: Element object, Node object #BREAK# C COLGROUP .align (Property) COLGROUP.align (Property) The alignment settings for a column group. Availability: DOM level 1 JavaScript 1.5 JScript 3.0 Internet Explorer 4.0 Netscape 6.0 Property/method value type: String primitive JavaScript syntax: -myCOLGROUP.align The alignment of the COLGROUP object with respect to its containing parent object is defined in this property. The following set of alignment specifiers are available: . absbottom . absmiddle . baseline . bottom . center . left . middle . right . texttop . top See also: COL.align COLGROUP.ch (Property) The alignment character for cells in a column group arrangement. Availability: DOM level 1 JavaScript 1.5 Netscape 6.0 Property/method value type: String primitive JavaScript syntax: N myTHEAD.ch HTML 4.0 provides for text to be arranged in neat columns within table cells without the need to create additional tables within tables. This method of alignment is selected by setting the ALIGN=”CHAR” HTML tag attribute. The CHAR HTML tag attribute is reflected in this property and is active when the CHAROFF HTML tag attribute is present. #BREAK# JavaScript Programmer’s Reference See also: COL.ch, TD.ch, TH.ch, THEAD.ch, TR.ch COLGROUP.chOff (Property) The offset of a column alignment character. Availability: DOM level 1 JavaScript 1.5 Netscape 6.0 Property/method value type: String primitive JavaScript syntax: N myTHEAD.chOff The CHARalignment style requires that an alignment character be specified with the ch property and that an offset measured in pixels be defined as its value. The offset value can be defined with the CHAROFF HTML tag attribute. The remainder of the string is offset by this distance from the alignment character. See also: COL.chOff, TD.chOff, TH.chOff, THEAD.chOff, TR.chOff COLGROUP.span (Property) The span settings for a column group. Availability: DOM level 1 JavaScript 1.5 JScript 3.0 Internet Explorer 4.0 Netscape 6.0 Property/method value type: Number primitive JavaScript syntax: -myCOLGROUP.span This property contains a definition of the number of adjacent columns that are affected by the tag’s attributes. It corresponds to the COLSPAN attributes of the
and tags and the objects that encapsulate them. See also: COL.span, TD.colSpan, TH.colSpan #BREAK# C COLGROUP .vAlign (Property) COLGROUP.vAlign (Property) The vertical alignment of items in a column group. Availability: DOM level 1 JavaScript 1.5 JScript 3.0 Internet Explorer 4.0 Netscape 6.0 Property/method value type: String primitive JavaScript syntax: -myCOLGROUP.vAlign This property controls text alignment in the vertical axis. This applies to text cells in the column group. The vAlign property may be set to these values: . baseline . bottom . middle . top See also: COL.vAlign COLGROUP.width (Property) The width of items in a column group. Availability: DOM level 1 JavaScript 1.5 JScript 3.0 Internet Explorer 4.0 Netscape 6.0 Property/method value type: Number primitive JavaScript syntax: -myCOLGROUP.width The columns within the column group are set to a width defined by this property. Changing the value will cause the page content to be re-flowed to reflect the new value. See also: COL.width #BREAK# JavaScript Programmer’s Reference Collation sequence (Definition) The order in which objects are sorted lexically according to the locale. Collation sequences determine the way that information is sorted into the correct sequence. This is likely to be very locale-dependant and therefore if you are going to sort data, you may need to provide a means of plugging in a sort comparator function that is aware of the national language variants if your scripts belong to sites that will be deployed in foreign languages. This is covered in some depth in the Unicode standard manual. See also: Localization Collection object (Object/DOM) An array of Element objects. Availability: DOM level 1 JavaScript 1.5 JScript 3.0 Internet Explorer 4.0 Netscape 6.0 Opera browser 3.0 IE myCollection = myDocument.all IE myCollection = myDocument.children IE myCollection = myDocument.filters -myCollection = myDocument.getElementsByName(aName)[anIndex] IE myCollection = myElement.all IE myCollection = myElement.children IE myCollection = myElement.filters JavaScript syntax: -myCollection = myDocument.getElementsByTagName(aTag)[anIndex] aName The nameattribute of an element anIndex A valid reference to an item in the collection Argument list: aTag The name of a tag Object properties: length Object methods: Item(), namedItem(), tags() A collection object is an enhancement to the basic array object to provide some additional searching capabilities for managing the contents of the document object model in a web browser. Do not confuse DOM NodeList arrays with Enumerator or Collection objects. The NodeListitem() method is subtly different from the Enumerator.Item() method. #BREAK# C Collection.Item() (Method) See also: TABLE.cells[] Property JavaScript JScript N IE Opera DOM Notes length 1.5 + 3.0 + 6.0 + 4.0 + 3.0 + 1 + ReadOnly Method JavaScript JScript N IE Opera DOM Notes Item() 1.5 + 3.0 + 6.0 + 4.0 + 5.0 + 1 + Warning namedItem() 1.5 + 5.0 + 6.0 + 5.0 + 5.0 + 1 + - tags() 3.0 + 4.0 + - Collection.Item() (Method) Select an Element object by index number. Availability: DOM level 1 JavaScript 1.5 JScript 3.0 Internet Explorer 4.0 Netscape 6.0 Opera 5.0 Property/method value type: Node object -myCollection.item(anIndex) -myCollection.item(aSelector) -myCollection.item(aSelector, anIndex) JavaScript syntax: -myCollection[anIndex] anIndex A zero based index into the collection Argument list: aSelector A textual value that selects all matching objects This is a search method that traverses a collection looking for an item or collection of items by the index in the collection. If the first argument is a numeric value, the object at the indexed position is returned. You may not place a second argument in the call. This is the DOM standard specified behavior. If the first argument is a string, then any object in the collection that has an ID or name property that matches the selector will be assembled into another collection. If there is no second argument, that new collection will be returned as a sub-set of the original receiving collection. This is an extension to the DOM specified behavior. If the first argument is a string and the second argument is a numeric value, the sub-set collection is manufactured but the element in that collection indexed by the second argument is returned as a single object. This is also an extension to the DOM specified behavior. #BREAK# JavaScript Programmer’s Reference This extension is useful because you can apply a filter and selection in one call without needing to extract and then store a sub-set collection. On the downside, this will repeat the sub-setting search each time it is called which can lead to performance problems. When using the myCollection.item(anIndex)syntax variation, it is functionally equivalent to myCollection[anIndex]. Note that the DOM specification does not allow for the alternative array-like addressing mode, which is implemented in browsers as a convenience. Warnings: . You may get back a single object if there is only one item that matches. However, if the selection criteria match more than one item, you will get back an array of objects. This is slightly problematic; it would be better if you consistently got back an array even if it contained zero or only one item. You could then operate on it consistently. . The Item() method of an MSIE Collection object is not the same as the item() method for the DOM NodeList object. The DOM specifies the method name in lower case, though it is upper case in MSIE (although JScript is somewhat forgiving of upper-lower case errors in scripts). . In addition, the Item() method of an MSIE Collectionsupports several different addressing modes, whereas the item() method of a Nodelistsupports only one. See also: Collection object, NamedNodeMap.item(), OptionsArray.item(), style.item() Collection.length (Property) Returns the length of a collection array. Availability: DOM level 1 JavaScript 1.5 JScript 3.0 Internet Explorer 4.0 Netscape 6.0 Opera 3.0 Property/method value type: Number primitive JavaScript syntax: -myCollection.length The collection behaves exactly like an array object and returns a number representing a count of all the elements in the collection. See also: AnchorArray.length, AppletArray.length, Arguments.length, Array.length, Attributes.length, Form.elements.length, Form.length, FormArray.length, LayerArray.length, LinkArray.length, NodeList.length, Plugin.length, PluginArray.length, ScriptArray.length, StyleSheetList.length, Window.length #BREAK# C Collection.namedItem() (Method) Property attributes: ReadOnly. Collection.namedItem() (Method) Select an Element object by nameor ID value. myCollection[aString] - aString A textual value that selects all matching objects This is a search method that traverses a collection looking for a named item or collection of items. The argument is a string containing the nameor IDvalue of the Element to be located. Argument list: Collection.tags() (Method) Extract a sub-list of Elementobjects of a particular tag type. Availability: DOM level 1 JavaScript 1.5 JScript 5.0 Internet Explorer 5.0 Netscape 6.0 Opera 5.0 Property/method value type: Node object -myCollection.namedItem(aString)JavaScript syntax: Availability: JScript 3.0 Internet Explorer 4.0 Property/method value type: Collection object JavaScript syntax: IE myCollection.tags(aTagName) Argument list: aTagName The name of a tag to be filtered The collection is traversed and all objects are examined to see if they were created by an HTML tag that is the same as that specified in the argument. The argument must always be specified in upper case and the resulting collection will contain all objects of that type selected from the receiving collection object. You can then manipulate the sub-set collection in the normal way, accessing items within it by index or by other means. See also: Collection object, Select.tags() #BREAK# JavaScript Programmer’s Reference Colon (:) (Delimiter) A delimiter used with labels and conditional operators. ECMAScript edition 2 JavaScript 1.2 JScript 3.0 Internet Explorer 4.0 Netscape 4.0 Availability: This delimiter is used with the case keyword and the default keyword in switch statement blocks. Refer to the switchtopic for details of how this is used. See also: switch( … ) … case: … default: … Color names (Definition) There are standard definitions of color names for use in web pages. Property/method value type: String primitive Although the color names are used in HTML tags, you can use Hexadecimal values as well. Here is a list of the standard color definitions: Name: Value: AliceBlue AntiqueWhite Aqua Aquamarine Azure Beige Bisque Black BlanchedAlmond Blue BlueViolet Brown BurleyWood CadetBlue Chartreuse Chocolate Coral CornFlowerBlue CornSilk Crimson #F0F8FF #FAEBD7 #00FFFF #7FFFD4 #F0FFFF #F5F5DC #FFE4C4 #000000 #FFEBCD #0000FF #8A2BE2 #A52A2A #DEB887 #5F9EA0 #7FFF00 #D2691E #FF7F50 #6495ED #FFF8DC #DC143C Table continued on following page #BREAK# C Color names (Definition) Name: Value: Cyan DarkBlue DarkCyan DarkGoldenrod DarkGray DarkGreen DarkKhaki DarkMagenta DarkOliveGreen DarkOrange DarkOrchid DarkRed DarkSalmon DarkSeaGreen DarkSlateBlue DarkSlateGray DarkTurquoise DarkViolet DeepPink DeepSkyBlue DimGray DodgerBlue Firebrick FloralWhite ForestGreen Fuchsia Gainsboro GhostWhite Gold Goldenrod Gray Green GreenYellow Honeydew HotPink IndianRed Indigo Ivory Khaki Lavender LavenderBlush LawnGreen LemonChiffon LightBlue #00FFFF #00008B #008B8B #B8860B #A9A9A9 #006400 #BDB76B #8B008B #556B2F #FF8C00 #9932CC #8B0000 #E9967A #8FBC8F #483D8B #2F4F4F #00CED1 #9400D3 #FF1493 #00BFFF #696969 #1E90FF #B22222 #FFFAF0 #228B22 #FF00FF #DCDCDC #F8F8FF #FFD700 #DAA520 #808080 #008000 #ADFF2F #F0FFF0 #FF69B4 #CD5C5C #4B0082 #FFFFF0 #F0E68C #E6E6FA #FFF0F5 #7CFC00 #FFFACD #ADD8E6 Table continued on following page #BREAK# JavaScript Programmer’s Reference Name: Value: LightCoral LightCyan LightGoldenrodYellow LightGray LightGreen LightPink LightSalmon LightSeaGreen LightSkyBlue LightSlateGray LightSteelBlue LightYellow Lime LimeGreen Linen Magenta Maroon MediumAquamarine MediumBlue MediumOrchid MediumPurple MediumSeaGreen MediumSlateBlue MediumSpringGreen MediumTurquoise MediumVioletRed MidnightBlue MintCream MistyRose Moccasin NavajoWhite Navy OldLace Olive OliveDrab Orange OrangeRed Orchid PaleGoldenrod PaleGreen PaleTurquoise PaleVioletRed PapayaWhip PeachPuff Peru #F08080 #E0FFFF #FAFAD2 #D3D3D3 #90EE90 #FFB6C1 #FFA07A #20B2AA #87CEFA #778899 #B0C4DE #FFFFE0 #00FF00 #32CD32 #FAF0E6 #FF00FF #800000 #66CDAA #0000CD #BA55D3 #9370DB #3CB371 #7B68EE #00FA9A #48D1CC #C71585 #191970 #F5FFFA #FFE4E1 #FFE4B5 #FFDEAD #000080 #FDF5E6 #808000 #6B8E23 #FFA500 #FF4500 #DA70D6 #EEE8AA #98FB98 #AFEEEE #DB7093 #FFEFD5 #FFDAB9 #CD853F Table continued on following page #BREAK# C Color names (Definition) Name: Value: Pink #FFC0CB Plum #DDA0DD PowderBlue #B0E0E6 Purple #800080 Red #FF0000 RosyBrown #BC8F8F RoyalBlue #4169E1 SaddleBrown #8B4513 Salmon #FA8072 SandyBrown #F4A460 SeaGreen #2E8B57 SeaShell #FFF5EE Sienna #A0522D Silver #C0C0C0 SkyBlue #87CEEB SlateBlue #6A5ACD SlateGray #708090 Snow #FFFAFA SpringGreen #00FF7F SteelBlue #4682B4 Tan #D2B48C Teal #008080 Thistle #D8BFD8 Tomato #FF6347 Turquoise #40E0D0 Violet #EE82EE Wheat #F5DEB3 White #FFFFFF WhiteSmoke #F5F5F5 Yellow #FFFF00 YellowGreen #9ACD32 If you prefer to compute the color names, there is a very neat color picker tool on the Netscape developer’s web site. See also: Color value Web-references: http://home.netscape.com/computing/webbuilding/studio/feature19981111-5.html #BREAK# JavaScript Programmer’s Reference Color value (Advice) Color values can be specified numerically or mnemonically. Property/method value type: String primitive A numeric color specification is a 6 digit (3 pairs) hexadecimal value with a leading hash symbol. Each pair of digits defines the intensity of a single color (RGB) in the display. The web-safe palette of 216 colors is defined by every possible combination of the following values: 00, 33, 66, 99, CC and FF There are other values supported through the mnemonic named color palette, which includes 100 shades of gray. You can use non-web-safe values if you have a greater than 8 bit deep display. These days most platforms can resolve at least 16 bits, but some legacy systems may have problems resolving non-web-safe colors. When using color values for defined styled colors, the rgb() function can be used. In the MSIE browser, the values can also be specified as 32 bit integer values, although in practice this is extremely difficult to manage. In certain circumstances, where an alpha value is available, the color value can be specified using hexadecimal notation to define a 32 bit integer. In this case, the value is comprised of four pairs of hex digits as follows: 0xAARRGGBB The value AA controls the alpha channel transparency, while the RR, GG, and BB values are the intensity of Red, Green and Blue respectively. When passed as a string value, the same hexadecimal value can be used but must be preceded by a hash rather than the 0x prefix. Thus 0xAARRGGBB becomes #AARRGGBB Warnings: . Be wary of spellings when specifying color values. The UK English spelling of “colour” will not set the property values you intend. Property values to do with color values will be spelled “color”. In addition some of the color names may be spelled in the American English tradition. See also: Colour names, rgb() #BREAK# C Comma expression (Definition) Comma expression (Definition) Used to separate individual operands or arguments. Availability: ECMAScript edition 2 Comma expressions occur rarely and are used to evaluate several expressions at once. See also: Comma operator (,), Expression Cross-references: ECMA 262 edition 2 section 11.14 ECMA 262 edition 3 section 11.14 Comma operator (,) (Delimiter) An argument separator token. ECMAScript edition 2 JavaScript 1.0 JScript 1.0 Internet Explorer 3.02 Netscape 2.0 Netscape Enterprise Server 2.0 Opera 3.0 Availability: The comma operator provides a way to evaluate several assignment expressions at once. It is provided as a way to express the arguments to a function in a manner consistent with the ECMA standard. It is also used in variable declaration lists to declare more than one variable with a single var statement. Its most subtle use is to exploit the side effects of an expression without assigning the result of that expression to anything. This is actually so subtle as to confuse what it’s actually doing. There is probably a simpler way to express the same functionality that doesn’t execute any slower and is a lot easier to maintain. The associativity is left to right. This means that the expressions should be executed in left to right order of appearance in the script source text. The result of the entire expression will be the evaluation of the last comma-separated item. It is not good style to use a comma separated list as an RValue in an assignment to an LValue. #BREAK# JavaScript Programmer’s Reference Example code: // Declaring several variables var e, c, d, x, y; // Arguments in a for iterator header for(a=0, b=0; a<10 ; a++, b++) { ; } // assign variables c = 1; d = 2; x = 3; y = 4; z = 5; // Add c to d and assign the result to e with incrementing // side effects e = (x++, y++, c) + (z--, d); See also: Associativity, Comma expression, Document.write(), Document.writeln(), Operator Precedence, var Cross-references: ECMA 262 edition 2 section 11.14 ECMA 262 edition 3 section 11.14 Wrox Instant JavaScript page 21 Comment (Definition) Sections of inactive code. Availability: ECMAScript edition 2 A comment is some text that is embedded within the script source text but is ignored by the interpreter. It is intended to provide guidance and documentation to the reader of the source code. Comments can be contained completely on a single line or can span multiple lines. A single-line comment can contain any character except for a line terminator. The line terminator at the end of the single line comment is not part of the comment and must obey the rules of placement of line terminators in general. Multiple-line comments are replaced by a single line terminator regardless of how many line terminators they actually contain. This means that a multiple-line comment behaves syntactically as if it were a line terminator. Warnings: . You cannot nest multi-line comments within one another. #BREAK# C Comment (// and /* ... */) (Delimiter) Comment (// and /* ... */), Escape sequence (), Lexical convention, Lexical element, Line, Multi-line comment, Script Source Text, Single line comment See also: Cross-references: ECMA 262 edition 2 section 6 ECMA 262 edition 2 section 7.3 ECMA 262 edition 2 section 7.8.2 ECMA 262 edition 3 section 6 ECMA 262 edition 3 section 7.4 O'Reilly JavaScript Definitive Guide page 29 Wrox Instant JavaScript page 17 Comment (// and /* ... */) (Delimiter) Mark a multi-line comment block. Availability: ECMAScript edition 2 JavaScript 1.0 JScript 1.0 Internet Explorer 3.02 Netscape 2.0 Netscape Enterprise Server 2.0 Opera 3.0 -/* First line of comment text -// Comment text -Second line of comment text JavaScript syntax: -Third line of comment text */ There are two kinds of comment blocks supported by JavaScript. They each have a different kind of delimiter. Single-line comments commence with a pair of slash characters (//) and stop at the end of the current line. Multi-line comments start with a slash-asterisk (/*) and finish at the first following asterisk-slash (*/). This means you cannot nest multiple line comment blocks inside one another. The disadvantage with that is that it is common practice in some languages to comment out sections of code by marking the start and end of the inactive sections as a multi-line comment block. This won't work if there are any multi-line comment blocks anywhere in this inactive block. A better technique, although slightly more cumbersome is to use single line comments (//) to 'switch-off' the lines of code you want to deactivate. Thus: //a = 1000; //b = 2000; //c = 3000; #BREAK# JavaScript Programmer's Reference See also: Comment, Lexical convention, Line, Line terminator, Multi-line comment, Single line comment Cross-references: ECMA 262 edition 2 section 7.3 ECMA 262 edition 3 section 7.4 COMMENT object (Object/DOM) An object that represents a section of HTML enclosed in comment delimiter tags. Availability: DOM level 1 JavaScript 1.5 JScript 3.0 Internet Explorer 4.0 Netscape 6.0 Inherits from: CharacterData object IE myCOMMENT = myDocument.all.anElementID IE myCOMMENT = myDocument.all.tags("COMMENT")[anIndex] IE myCOMMENT = myDocument.all[aName] -myCOMMENT = myDocument.getElementById(anElementID) -myCOMMENT = myDocument.getElementsByName(aName)[anIndex] N myCOMMENT = myDocument.createComment(aString) JavaScript syntax: -myCOMMENT = myDocument.getElementsByTagName("COMMENT")[anIndex] HTML syntax: anIndex An item within the collection aString A comment string aName The name of an element Argument list: anElementID The ID attribute of an element Object properties: text Object methods: Collections: click(), getAttribute(), removeAttribute(), setAttribute() all[], children[] It is somewhat unlikely you would ever want to modify the contents of a comment tag. However, access to the text contained within it may be a way of passing hidden data values to your scripts without them being visible in the displayed page. Of course they would still be visible in the document source, but you might be able to avoid the creation of a
and hidden object. #BREAK# C COMMENT.text (Property) Warnings: . The DOM level 1 specification describes this as a Comment object, but MSIE implements it as a COMMENT object instead. You may need to be aware of this in case other platforms implement the DOM specified class exactly as it is intended. See also: CharacterData object, Document.createComment(), Element object, Hiding scripts from old browsers Property JavaScript JScript N IE Opera DOM Notes text 3.0 + 4.0 + - Method JavaScript JScript N IE Opera DOM Notes click() 1.5 + 3.0 + 6.0 + 4.0 + 1 + Warning getAttribute() 1.5 + 3.0 + 6.0 + 4.0 + 1 + Warning removeAttribute() 1.5 + 3.0 + 6.0 + 4.0 + 1 + Warning setAttribute() 1.5 + 3.0 + 6.0 + 4.0 + 1 + Warning Inheritance chain: CharacterData object, Node object COMMENT.text (Property) The text within a comment block. Availability: JScript 3.0 Internet Explorer version 4.0 Property/method value type: String primitive JavaScript syntax: IE myCOMMENT.text This is the internal text within the comment block. The DOM standard treats comment blocks as character data to standardize the access to their content, but you should not expect to be able to access the internal text of a comment for any functional purpose. Compatibility (Definition) Creating web content is an exercise in portable programming that would severely test the most experienced programmer. There are so many issues to do with portability and compatibility that unless you are doing something very simple, its is an amazing achievement to get your web page to display even remotely similarly on several browsers or platforms. #BREAK# JavaScript Programmer’s Reference Leaving aside the creative issues to do with color matching, gamma correction, and display resolution, there are problems with fonts, style sheets and table layout. Layers and dynamic HTML behave differently even within the same browser family as the browsers are revised. Even scrolling a page means you have to increment the scroll value in opposite directions in Netscape and MSIE, and Netscape won’t scroll at all without the scroll bars being visible. To cope with this, it helps to break the compatibility issues down into sub-sets and to understand the underlying reason for incompatibility. You do need to know about and be able to identify issues based on platforms, browsers, or versions of client software. See also: