JavaScript Object Reference (5)
The string Object
The string object provides properties and methods for working with string literals and variables.
Properties
- length
- An integer value containing the length of the string expressed as the number of characters in the string.
Methods
- anchor(name)
- Returns a string containing the value of the string object surrounded by an A container tag with the NAME attribute set to name.
- big()
- Returns a string containing the value of the string object surrounded by a BIG container tag.
- blink()
- Returns a string containing the value of the string object surrounded by a BLINK container tag.
- bold()
- Returns a string containing the value of the string object surrounded by a B container tag.
- charAt(index)
- Returns the character at the location specified by index.
- fixed()
- Returns a string containing the value of the string object surrounded by a FIXED container tag.
- fontColor(color)
- Returns a string containing the value of the string object surrounded by a FONT container tag with the COLOR attribute set to color where color is a color name or an RGB triplet.
- fontSize(size)
- Returns a string containing the value of the string object surrounded by a FONTSIZE container tag with the size set to size.
- indexOf(findString,startingIndex)
- Returns the index of the first occurrence of findString, starting the search at startingIndex where startingIndex is optional; if it is not provided, the search starts at the start of the string.
- italics()
- Returns a string containing the value of the string object surrounded by an I container tag.
- lastIndexOf(findString,startingIndex)
- Returns the index of the last occurrence of findString. This is done by searching backwards from startingIndex. startingIndex is optional and assumed to be the last character in the string if no value is provided.
- link(href)
- Returns a string containing the value of the string object surrounded by an A container tag with the HREF attribute set to href.
- small()
- Returns a string containing the value of the string object surrounded by a SMALL container tag.
- strike()
- Returns a string containing the value of the string object surrounded by a STRIKE container tag.
- sub()
- Returns a string containing the value of the string object surrounded by a SUB container tag.
- substring(firstIndex,lastIndex)
- Returns a string equivalent to the substring starting at firstIndex and ending at the character before lastIndex. If firstIndex is greater than lastIndex, the string starts at lastIndex and ends at the character before firstIndex.
- sup()
- Returns a string containing the value of the string object surrounded by a SUP container tag.
- toLowerCase()
- Returns a string containing the value of the string object with all characters converted to lower case.
- toUpperCase()
- Returns a string containing the value of the string object with all characters converted to upper case.
The submit Object
The submit object reflects a submit button from an HTML form in JavaScript.
Properties
- name
- A string value containing the name of the submit button element.
- value
- A string value containing the value of the submit button element.
Methods
- click()
- Emulates the action of clicking on the submit button.
Event Handlers
- onClick
- Specifies JavaScript code to execute when the submit button is clicked.
The text Object
The text object reflects a text field from an HTML form in JavaScript.
Properties
- defaultValue
- A string value containing the default value of the text element (i.e. the value of the VALUE attribute).
- name
- A string value containing the name of the text element.
- value
- A string value containing the value of the text element.
Methods
- focus()
- Emulates the action of focusing in the text field.
- blur()
- Emulates the action of removing focus from the text field.
- select()
- Emulates the action of selecting the text in the text field.
Event Handlers
- onBlur
- Specifies JavaScript code to execute when focus is removed from the field.
- onChange
- Specifies JavaScript code to execute when the content of the field is changed.
- onFocus
- Specifies JavaScript code to execute when focus is given to the field.
- onSelect
- Specifies JavaScript code to execute when the user selects some or all of the text in the field.
Previous | Contents | Next
|