ÄúµÄλÖãºÑ°ÃÎÍøÊ×Ò³£¾±à³ÌÀÖÔ°£¾JavaScript£¾JavaScript Notes

Properties

The following properties are available in JavaScript:

  • action
  • alinkColor
  • anchors
  • appCodeName
  • appName
  • appVersion
  • bgColor
  • checked
  • cookie
  • defaultChecked
  • defaultSelected
  • defaultStatus
  • defaultValue
  • E
  • elements
  • encoding
  • fgColor
  • forms
  • frames
  • hash
  • host
  • hostname
  • href
  • index
  • lastModified
  • length
  • linkColor
  • links
  • LN2
  • LN10
  • location
  • LOG2E
  • LOG10E
  • method
  • name
  • options
  • parent
  • pathname
  • PI
  • port
  • protocol
  • referrer
  • search
  • selected
  • selectedIndex
  • self
  • SQRT1_2
  • SQRT2
  • status
  • target
  • text
  • title
  • top
  • userAgent
  • value
  • vlinkColor
  • window

  • (A-L)

    action property

    A string specifying a destination URL for form data that is submitted.

    Syntax

    formName.action

    formName is either the name of a form or an element in the forms array.

    Description

    The action property is a reflection of the ACTION attribute of the <FORM> tag. Each section of a URL contains different information. See the location object for a description of the URL components.

    You can set the action property at any time.

    Certain values of the action property may require specific values for other form properties. See RFC 1867 for more information.

    Property of

    form

    Examples

    The following example sets the action property of the musicForm form to the value of the variable urlName:

    document.musicForm.action=urlName

    See also

  • encoding, method, target properties

    alinkColor property

    A string specifying the color of an active link (after mouse-button down, but before mouse-button up).

    Syntax

    document.alinkColor

    Description

    The alinkColor property is expressed as a hexadecimal RGB triplet or as one of the string literals listed in Color Values. This property is the JavaScript reflection of the ALINK attribute of the <BODY> tag. You cannot set this property after the HTML source has been through layout.

    If you express the color as a hexadecimal RGB triplet, you must use the format rrggbb. For example, the hexadecimal RGB values for salmon are red=FA, green=80, and blue=72, so the RGB triplet for salmon is "FA8072".

    Property of

    document

    Examples

    The following example sets the color of active links to aqua using a string literal:

    document.alinkColor="aqua"
    

    The following example sets the color of active links to aqua using a hexadecimal triplet:

    document.alinkColor="00FFFF"
    

    See also

  • bgColor, fgColor, linkColor, and vlinkColor properties

    anchors property

    An array of objects corresponding to named anchors in source order. See anchor object.


    appCodeName property

    A string specifying the code name of the browser.

    Syntax

    navigator.appCodeName

    Description

    appCodeName is a read-only property.

    Property of

    navigator

    Examples

    The following example displays the value of the appCodeName property:

    document.write("The value of navigator.appCodeName is " +
       navigator.appCodeName)

    For Navigator 2.0, this displays the following:

    The value of navigator.appCodeName is Mozilla

    See also

  • appName, appVersion, userAgent properties

    appName property

    A string specifying the name of the browser.

    Syntax

    navigator.appName

    Description

    appName is a read-only property.

    Property of

    navigator

    Examples

    The following example displays the value of the appName property:

    document.write("The value of navigator.appName is " +
       navigator.appName)

    For Navigator 2.0, this displays the following:

    The value of navigator.appName is Netscape

    See also

  • appVersion, appCodeName, userAgent properties

    appVersion property

    A string specifying version information for the Navigator.

    Syntax

    navigator.appVersion

    Description

    The appVersion property specifies version information in the following format:

    releaseNumber (platform; country)

    The values contained in this format are the following:

  • releaseNumber is the version number of the Navigator. For example, "2.0b4" specifies Navigator 2.0, beta 4.
  • platform is the platform upon which the Navigator is running. For example, "Win16" specifies a 16-bit version of Windows such as Windows 3.11.
  • country is either "I" for the international release, or "U" for the domestic U.S. release. The domestic release has a stronger encryption feature than the international release.

    appVersion is a read-only property.

    Property of

    navigator

    Examples

    Example 1. The following example displays version information for the Navigator:

    document.write("The value of navigator.appVersion is " +
       navigator.appVersion)

    For Navigator 2.0 on Windows 95, this displays the following:

    The value of navigator.appVersion is 2.0 (Win95, I)

    Example 2. The following example populates a textarea object with newline characters separating each line. Because the newline character varies from platform to platform, the example tests the appVersion property to determine whether the user is running Windows (appVersion contains "Win" for all versions of Windows). If the user is running Windows, the newline character is set to \r\n; otherwise, it's set to \n, which is the newline character for Unix and Macintosh.

    <SCRIPT> var newline=null function populate(textareaObject){ if (navigator.appVersion.lastIndexOf('Win') != -1) newline="\r\n" else newline="\n" textareaObject.value="line 1" + newline + "line 2" + newline + "line 3" } </SCRIPT> <FORM NAME="form1"> <BR><TEXTAREA NAME="testLines" ROWS=8 COLS=55></TEXTAREA> <P><INPUT TYPE="button" VALUE="Populate the textarea object" onClick="populate(document.form1.testLines)"> </TEXTAREA> </FORM>

    See also

  • appName, appCodeName, userAgent properties

    bgColor property

    A string specifying the color of the document background.

    Syntax

    document.bgColor

    Description

    The bgColor property is expressed as a hexadecimal RGB triplet or as one of the string literals listed in Color Values. This property is the JavaScript reflection of the BGCOLOR attribute of the <BODY> tag. The default value of this property is set by the user on the Colors tab of the Preferences dialog box, which is displayed by choosing General Preferences from the Options menu.

    You can set the bgColor property at any time.

    If you express the color as a hexadecimal RGB triplet, you must use the format rrggbb. For example, the hexadecimal RGB values for salmon are red=FA, green=80, and blue=72, so the RGB triplet for salmon is "FA8072".

    Property of

    document

    Examples

    The following example sets the color of the document background to aqua using a string literal:

    document.bgColor="aqua"
    

    The following example sets the color of the document background to aqua using a hexadecimal triplet:

    document.bgColor="00FFFF"
    

    See also

  • alinkColor, fgColor, linkColor, and vlinkColor properties

    checked property

    A Boolean value specifying the selection state of a checkbox object or radio button.

    Syntax

    1. checkboxName.checked
    2. radioName[index].checked
    

    checkboxName is either the value of the NAME attribute of a checkbox object or an element in the elements array.
    radioName is the value of the NAME attribute of a radio object.
    index is an integer representing a radio button in a radio object.

    Description

    If a checkbox or radio button is selected, the value of its checked property is true; otherwise, it is false.

    You can set the checked property at any time. The display of the checkbox or radio button updates immediately when you set the checked property.

    Property of

    checkbox, radio

    Examples

    The following example examines an array of radio buttons called musicType on the musicForm form to determine which button is selected. The VALUE attribute of the selected button is assigned to the checkedButton variable.

    function stateChecker() {
       var checkedButton = ""
       for (var i in document.musicForm.musicType) {
          if (document.musicForm.musicType[i].checked=="1") {
             checkedButton=document.musicForm.musicType[i].value
          }
       }
    }
    

    See also

  • defaultChecked property

    cookie property

    String value of a cookie, which is a small piece of information stored by the Navigator in the cookies.txt file.

    Syntax

    document.cookie

    Description

    Use string methods such as substring, charAt, indexOf, and lastIndexOf to determine the value stored in the cookie. See the Netscape cookie specification for a complete specification of the cookie syntax.

    You can set the cookie property at any time.

    Property of

    document

    Examples

    The following function uses the cookie property to record a reminder for users of an application. The "expires=" component sets an expiration date for the cookie, so it persists beyond the current browser session.

    function RecordReminder(time, expression) {
       // Record a cookie of the form "@<T>=<E>" to map
       // from <T> in milliseconds since the epoch,
       //  returned by Date.getTime(), onto an encoded expression,
       // <E> (encoded to contain no white space, semicolon,
       // or comma characters)
       document.cookie = "@" + time + "=" + expression + ";"
       // set the cookie expiration time to one day
       // beyond the reminder time
       document.cookie += "expires=" + Date(time + 24*60*60*1000)
    }
    

    When the user loads the page that contains this function, another function uses indexOf("@") and indexOf("=") to determine the date and time stored in the cookie.

    See also

  • hidden object

    defaultChecked property

    A Boolean value indicating the default selection state of a checkbox or radio button.

    Syntax

    1. checkboxName.defaultChecked
    2. radioName[index].defaultChecked
    

    checkboxName is either the value of the NAME attribute of a checkbox object or an element in the elements array.
    radioName is the value of the NAME attribute of a radio object.
    index is an integer representing a radio button in a radio object.

    Description

    If an checkbox or radio button is selected by default, the value of the defaultChecked property is true; otherwise, it is false. defaultChecked initially reflects whether the CHECKED attribute is used within an <INPUT> tag; however, setting defaultChecked overrides the CHECKED attribute.

    You can set the defaultChecked property at any time. The display of the checkbox or radio button does not update when you set the defaultChecked property, only when you set the checked property.

    Property of

    checkbox, radio

    Examples

    The following example resets an array of radio buttons called musicType on the musicForm form to the default selection state.

    function radioResetter() {
       var i=""
       for (i in document.musicForm.musicType) {
          if (document.musicForm.musicType[i].defaultChecked==true) {
             document.musicForm.musicType[i].checked=true
          }
       }
    }
    

    See also

  • checked property

    defaultSelected property

    A Boolean value indicating the default selection state of an option in a select object.

    Syntax

    selectName.options[index].defaultSelected

    selectName is either the value of the NAME attribute of a select object or an element in the elements array.
    index is an integer representing an option in a select object.

    Description

    If an option in a select object is selected by default, the value of the defaultSelected property is true; otherwise, it is false. defaultSelected initially reflects whether the SELECTED attribute is used within an <OPTION> tag; however, setting defaultSelected overrides the SELECTED attribute.

    You can set the defaultSelected property at any time. The display of the select object does not update when you set the defaultSelected property, only when you set the selected or selectedIndex properties.

    A select object created without the MULTIPLE attribute can have only one option selected by default. When you set defaultSelected in such an object, any previous default selections, including defaults set with the SELECTED attribute, are cleared. If you set defaultSelected in a select object created with the MULTIPLE attribute, previous default selections are not affected.

    Property of

    options array

    Examples

    In the following example, the restoreDefault() function returns the musicType select object to its default state. The for loop uses the options array to evaluate every option in the select object. The if statement sets the selected property if defaultSelected is true.

    function restoreDefault() {
       for (var i = 0; i < document.musicForm.musicType.length; i++) {
          if (document.musicForm.musicType.options[i].defaultSelected == true) {
             document.musicForm.musicType.options[i].selected=true
          }
       }
    }
    
    The previous example assumes that the select object is similar to the following:
    <SELECT NAME="musicType">
       <OPTION SELECTED> R&B
       <OPTION> Jazz
       <OPTION> Blues
       <OPTION> New Age
    </SELECT>
    

    See also

  • index, selected, selectedIndex properties

    defaultStatus property

    The default message displayed in the status bar at the bottom of the window.

    Syntax

    windowReference.defaultStatus

    windowReference is a valid way of referring to a window, as described in the window object.

    Description

    The defaultStatus message appears when nothing else is in the status bar. Do not confuse the defaultStatus property with the status property. The status property reflects a priority or transient message in the status bar, such as the message that appears when a mouseOver event occurs over an anchor.

    You can set the defaultStatus property at any time. You must return true if you want to set the defaultStatus property in the onMouseOver event handler.

    Property of

    window

    Examples

    In the following example, the statusSetter() function sets both the status and defaultStatus properties in an onMouseOver event handler:

    function statusSetter() {
       window.defaultStatus = "Click the link for the Netscape home page"
       window.status = "Netscape home page"
    }
    
    <A HREF="http://www.netscape.com"
       onMouseOver = "statusSetter(); return true">Netscape</A>
    
    In the previous example, notice that the onMouseOver event handler returns a value of true. You must return true to set status or defaultStatus in an event handler.

    See also

  • status property

    defaultValue property

    A string indicating the default value of a password, text, or textarea object.

    Syntax

    1. passwordName.defaultValue
    2. textName.defaultValue
    3. textareaName.defaultValue
    

    passwordName is either the value of the NAME attribute of a password object or an element in the elements array.
    textName is either the value of the NAME attribute of a text object or an element in the elements array.
    textareaName is either the value of the NAME attribute of a textarea object or an element in the elements array.

    Description

    The initial value of defaultValue differs for each object:

  • For text objects, it initially reflects the value of the VALUE attribute.
  • For textarea objects, it initially reflects the value specified between the <TEXTAREA> and </TEXTAREA> tags.
  • For password objects, it initially is null (for security reasons), regardless of the value of the VALUE attribute.

    Setting defaultValue programatically overrides the initial setting. If you programatically set defaultValue for the password object and then evaluate it, JavaScript returns the current value.

    You can set the defaultValue property at any time. The display of the related object does not update when you set the defaultValue property, only when you set the value property.

    Property of

    hidden, password, text, textarea

    Examples

    The following function evaluates the defaultValue property of objects on the surfCity form and displays the values in the msgWindow window:

    function defaultGetter() {
       msgWindow=window.open("")
       msgWindow.document.write("hidden.defaultValue is " +
          document.surfCity.hiddenObj.defaultValue + "<BR>")
       msgWindow.document.write("password.defaultValue is " +
          document.surfCity.passwordObj.defaultValue + "<BR>")
       msgWindow.document.write("text.defaultValue is " +
          document.surfCity.textObj.defaultValue + "<BR>")
       msgWindow.document.write("textarea.defaultValue is " +
          document.surfCity.textareaObj.defaultValue + "<BR>")
       msgWindow.document.close()
    }
    

    See also

  • value property

    E property

    Euler's constant and the base of natural logarithms, approximately 2.718.

    Syntax

    Math.E

    Description

    Because E is a constant, it is a read-only property of Math.

    Property of

    Math

    Examples

    The following example displays Euler's constant:

    document.write("Euler's constant is " + Math.E)

    See also

  • LN2, LN10, LOG2E, LOG10E, PI, SQRT1_2, SQRT2 properties

    elements property

    An array of objects corresponding to form elements (such as checkbox, radio, and text objects) in source order. See elements array.


    encoding property

    A string specifying the MIME encoding of the form.

    Syntax

    formName.encoding

    formName is either the name of a form or an element in the forms array.

    Description

    The encoding property initially reflects the ENCTYPE attribute of the <FORM> tag; however, setting encoding overrides the ENCTYPE attribute.

    You can set the encoding property at any time.

    Certain values of the encoding property may require specific values for other form properties. See RFC 1867 for more information.

    Property of

    form

    Examples

    The following function returns the value of the musicForm encoding property:

    function getEncoding() {
       return document.musicForm.encoding
    }
    

    See also

  • action, method, target properties

    fgColor property

    A string specifying the color of the document text.

    Syntax

    document.fgColor

    Description

    The fgColor property is expressed as a hexadecimal RGB triplet or as one of the string literals listed in Color Values. This property is the JavaScript reflection of the TEXT attribute of the <BODY> tag. The default value of this property is set by the user on the Colors tab of the Preferences dialog box, which is displayed by choosing General Preferences from the Options menu. You cannot set this property after the HTML source has been through layout.

    If you express the color as a hexadecimal RGB triplet, you must use the format rrggbb. For example, the hexadecimal RGB values for salmon are red=FA, green=80, and blue=72, so the RGB triplet for salmon is "FA8072".

    You can override the value set in the fgColor property in either of the following ways:

  • Setting the COLOR attribute of the <FONT> tag.
  • Using the fontcolor method.

    Property of

    document

    Examples

    The following example sets the color of the foreground text to aqua using a string literal:

    document.fgColor="aqua"
    

    The following example sets the color of the foreground text to aqua using a hexadecimal triplet:

    document.fgColor="00FFFF"
    

    See also

  • alinkColor, bgColor, linkColor, and vlinkColor properties
  • fontcolor

    forms property

    An array of objects corresponding to the forms (<FORM> tags) in a document in source order. See form object.


    frames property

    An array of objects corresponding to child frames (<FRAME> tag) in source order. See frame object.


    hash property

    A string beginning with a hash mark (#) that specifies an anchor name in the URL.

    Syntax

    location.hash

    Description

    The hash property specifies a portion of the URL.

    You can set the hash property at any time, although it is safer to set the href property to change a location. If the hash that you specify cannot be found in the current location, you will get an error.

    See RFC 1738> for complete information about the hash.

    Property of

    link, location

    Examples

    See the examples for the anchor object and the href property.

    See also

  • host, hostname, href, pathname, port, protocol, search properties

    host property

    A string specifying the hostname:port portion of the URL.

    Syntax

    location.host

    Description

    The host property specifies a portion of the URL. The host property is the concatenation of the hostname and port properties, separated by a colon. When the port property is null, the host property is the same as the hostname property.

    You can set the host property at any time, although it is safer to set the href property to change a location. If the host that you specify cannot be found in the current location, you will get an error.

    See Section 3.1 of RFC 1738 for complete information about the hostname and port.

    Property of

    link, location

    Examples

    See the examples for the href property.

    See also

  • hash, hostname, href, pathname, port, protocol, search properties

    hostname property

    A string specifying the host and domain name, or IP address, of a network host.

    Syntax

    location.hostname

    Description

    The hostname property specifies a portion of the URL. The hostname property is a substring of the host property. The host property is the concatenation of the hostname and port properties, separated by a colon. When the port property is null, the host property is the same as the hostname property.

    You can set the hostname property at any time, although it is safer to set the href property to change a location. If the hostname that you specify cannot be found in the current location, you will get an error.

    See Section 3.1 of RFC 1738 for complete information about the hostname.

    Property of

    link, location

    Examples

    See the examples for the href property.

    See also

  • hash, host, href, pathname, port, protocol, search properties

    href property

    A string specifying the entire URL.

    Syntax

    location.href

    Description

    The href property specifies the entire URL. Other location object properties are substrings of the href property. You can set the href property at any time.

    See RFC 1738 for complete information about the URL.

    Property of

    link, location

    Examples

    In the following example, the window.open statement creates a window called newWindow and loads the specified URL into it. The document.write statements display all the properties of newWindow.location in a window called msgWindow.

    newWindow=window.open
       ("http://home.netscape.com/comprod/products/navigator/
       version_2.0/script/script_info/objects.html#checkbox_object")
    
    msgWindow.document.write("newWindow.location.href = " +
       newWindow.location.href + "<P>")
    msgWindow.document.write("newWindow.location.protocol = " +
       newWindow.location.protocol + "<P>")
    msgWindow.document.write("newWindow.location.host = " +
       newWindow.location.host + "<P>")
    msgWindow.document.write("newWindow.location.hostName = " +
       newWindow.location.hostName + "<P>")
    msgWindow.document.write("newWindow.location.port = " +
       newWindow.location.port + "<P>")
    msgWindow.document.write("newWindow.location.pathname = " +
       newWindow.location.pathname + "<P>")
    msgWindow.document.write("newWindow.location.search = " +
       newWindow.location.search + "<P>")
    msgWindow.document.write("newWindow.location.hash = " +
       newWindow.location.hash + "<P>")
    msgWindow.document.close()
    

    The previous example displays output such as the following:

    newWindow.location.href =
       http://home.netscape.com/comprod/products/navigator/
       version_2.0/script/script_info/objects.html#checkbox_object
    newWindow.location.protocol = http:
    newWindow.location.host = home.netscape.com
    newWindow.location.hostName = home.netscape.com
    newWindow.location.port =
    newWindow.location.pathname =
       /comprod/products/navigator/version_2.0/script/
       script_info/objects.html
    newWindow.location.search =
    newWindow.location.hash = #checkbox_object
    

    See also

  • hash, host, hostname, pathname, port, protocol, search properties

    index property

    An integer representing the index of an option in a select object.

    Syntax

    selectName.options[indexValue].index
    

    selectName is either the value of the NAME attribute of a select object or an element in the elements array.
    indexValue is an integer representing an option in a select object.

    Description

    The number identifying the position of the option in the selection, starting from zero.

    Property of

    options array

    See also

  • defaultSelected, selected, selectedIndex properties

    lastModified property

    A string representing the date that a document was last modified.

    Syntax

    document.lastModified

    Description

    lastModified is a read-only property.

    Property of

    document

    Examples

    In the following example, the lastModified property is used in a <SCRIPT> tag at the end of an HTML file to display the modification date of the page:

    document.write("This page updated on " + document.lastModified)
    

    length property

    An integer that specifies a length-related feature of the calling object or array.

    Syntax

    When used with objects:

    1. formName.length
    2. frameReference.length
    3. history.length
    4. radioName.length
    5. selectName.length
    6. stringName.length
    7. windowReference.length
    

    When used with array properties:

    8. anchors.length
    9. elements.length
    10. forms.length
    11. frameReference.frames.length
    12. windowReference.frames.length
    13. links.length
    14. selectName.options.length
    

    formName is either the name of a form or an element in the forms array.
    frameReference is either the value of the NAME attribute of a frame or an element in the frames array.
    radioName is either the value of the NAME attribute of a radio object or an element in the elements array.
    selectName is either the value of the NAME attribute of a select object or an element in the elements array.
    stringName is any string or a property of an existing object.
    windowReference is a valid way of referring to a window, as described in the window object.

    Description

    The length property is an integer that specifies one of the following:

  • The number of elements on a form (form 1 of the syntax).
  • The number of frames within a frame (form 2 of the syntax). A frame that does not load a document containing a <FRAMESET> tag always has a length of 0.
  • The number of entries in a history object (form 3 of the syntax).
  • The number of radio buttons in a radio object (form 4 of the syntax).
  • The number of options in a select object (form 5 of the syntax).
  • The length of a string object (form 6 of the syntax).
  • The number of frames in a parent window (form 7 of the syntax).
  • The number of entries in one of the array properties (all other syntax forms).

    length is always a read-only property.

    For a null string, length is zero. For a select object, the values returned by form 5 and form 14 of the syntax are the same. For a window containing frames, the values returned by form 7 and form 12 of the syntax are the same. For a form object, the values returned by form 1 and form 9 of the syntax are the same. For a frame containing frames, the values returned by form 2 and form 11 of the syntax are the same.

    Property of

  • frame, history, radio, select, string, window objects
  • anchors, elements, forms, frames, links, options arrays

    Examples

    In the following example, the getChoice() function uses the length property to iterate over every element in the musicType array. musicType is a select element on the musicForm form.

    function getChoice() {
       for (var i = 0; i < document.musicForm.musicType.length; i++) {
          if (document.musicForm.musicType.options[i].selected == true) {
             return document.musicForm.musicType.options[i].text
          }
       }
    }
    

    The following example displays 8 in an alert dialog box:

    var x="Netscape"
    alert("The string length is " + x.length)
    

    linkColor property

    A string specifying the color of the document hyperlinks.

    Syntax

    document.linkColor

    Description

    The linkColor property is expressed as a hexadecimal RGB triplet or as one of the string literals listed in Color Values. This property is the JavaScript reflection of the LINK attribute of the <BODY> tag. The default value of this property is set by the user on the Colors tab of the Preferences dialog box, which is displayed by choosing General Preferences from the Options menu. You cannot set this property after the HTML source has been through layout.

    If you express the color as a hexadecimal RGB triplet, you must use the format rrggbb. For example, the hexadecimal RGB values for salmon are red=FA, green=80, and blue=72, so the RGB triplet for salmon is "FA8072".

    Property of

    document

    Examples

    The following example sets the color of document links to aqua using a string literal:

    document.linkColor="aqua"
    

    The following example sets the color of document links to aqua using a hexadecimal triplet:

    document.linkColor="00FFFF"
    

    See also

  • alinkColor, bgColor, fgColor, and vlinkColor properties

    links property

    An array of objects corresponding to link objects in source order. See link object.


    LN2 property

    The natural logarithm of two, approximately 0.693.

    Syntax

    Math.LN2

    Description

    Because LN2 is a constant, it is a read-only property of Math.

    Property of

    Math

    Examples

    The following example displays the natural log of 2:

    document.write("The natural log of 2 is " + Math.LN2)

    See also

  • E, LN10, LOG2E, LOG10E, PI, SQRT1_2, SQRT2 properties

    LN10 property

    The natural logarithm of ten, approximately 2.302.

    Syntax

    Math.LN10

    Description

    Because LN10 is a constant, it is a read-only property of Math.

    Property of

    Math

    Examples

    The following example displays the natural log of 10:

    document.write("The natural log of 10 is " + Math.LN10)

    See also

  • E, LN2, LOG2E, LOG10E, PI, SQRT1_2, SQRT2 properties

    location property

    A string specifying the complete URL of the document.

    Syntax

    document.location

    Description

    Do not confuse the location property of the document object with the location object. You cannot change the value of the location property (document.location), but you can change the value of the location object's properties (window.location.propertyName). document.location is a string-valued property that usually matches what window.location is set to when you load the document, but redirection may change it.

    location is a read-only property of document.

    Property of

    document

    Examples

    The following example displays the URL of the current document:

    document.write("The current URL is " + document.location)
    

    See also

  • location object

    LOG2E property

    The base 2 logarithm of e (approximately 1.442).

    Syntax

    Math.LOG2E

    Description

    Because LOG2E is a constant, it is a read-only property of Math.

    Property of

    Math

    Examples

    The following example displays the base 2 logarithm of E:

    document.write("The base 2 logarithm of E is " + Math.LOG2E)

    See also

  • E, LN2, LN10, LOG10E, PI, SQRT1_2, SQRT2 properties

    LOG10E property

    The base 10 logarithm of e (approximately 0.434).

    Syntax

    Math.LOG10E

    Description

    Because LOG10E is a constant, it is a read-only property of Math.

    Property of

    Math

    Examples

    The following example displays the base 10 logarithm of E:

    document.write("The base 10 logarithm of E is " + Math.LOG10E)

    See also

  • E, LN2, LN10, LOG2E, PI, SQRT1_2, SQRT2 properties
    (M-Z)

    method property

    A string specifying how form field input information is sent to the server.

    Syntax

    formName.method

    formName is either the name of a form or an element in the forms array.

    Description

    The method property is a reflection of the METHOD attribute of the <FORM> tag. The method property should evaluate to either "get" or "post".

    You can set the method property at any time.

    Certain values of the method property may require specific values for other form properties. See RFC 1867 for more information.

    Property of

    form

    Examples

    The following function returns the value of the musicForm method property:

    function getMethod() {
      return document.musicForm.method
    }
    

    See also

  • action, encoding, target properties

    name property

    A string specifying the name of an object.

    Syntax

    1. objectName.name
    2. frameReference.name
    3. frameReference.frames.name
    4. radioName[index].name
    5. selectName.options.name
    6. windowReference.name
    7. windowReference.frames.name
    

    objectName is either the value of the NAME attribute of any of the objects listed below or an element in the elements array.
    frameReference is a valid way of referring to a frame, as described in the frame object.
    radioName is the value of the NAME attribute of a radio object.
    selectName is either the value of the NAME attribute of a select object or an element in the elements array.
    windowReference is a valid way of referring to a window, as described in the window object.

    Description

    The value of the name property differs between the window object and other objects.

    window object

    The name property for the window object is represented by form 6 and form 7 of the syntax. The name property represents the value of the windowName argument described in the window object syntax. Both forms of the syntax represent the same value.

    name is a read-only property.

    All other objects

    The name property for all objects except window is represented by forms 1 through 5 of the syntax. For all objects except window, the name property initially reflects the value of the NAME attribute. Changing the name property overrides this setting.

    You can set the name property at any time.

    The name property is the same for every radio button in a single radio object. Individual radio buttons are referenced by their position in the radio array.

    Do not confuse the name property with the label displayed on a button, reset, or submit object. The value property specifies the label for these objects. The name property is not displayed onscreen; it is used to reference the objects programatically.

    For a select object, the values specified by form 1 and form 5 of the syntax are the same. For a frame object, the values specified by forms 1, 2, and 3 of the syntax are the same.

    If multiple objects on the same form have the same NAME attribute, an array of the given name is created automatically. Each element in the array represents an individual form object. Elements are indexed in source order starting at 0. For example, if two text elements and a textarea element on the same form have their NAME attribute set to "myField", an array with the elements myField[0], myField[1], and myField[2] is created.

    Property of

  • button, checkbox, frame, hidden, password, radio, reset, select, submit, text, textarea, window
  • options array

    Examples

    In the following example, the valueGetter() function uses a for loop to iterate over the array of elements on the valueTest form. The msgWindow window displays the names of all the elements on the form:

    newWindow=window.open("http://www.netscape.com")
    
    function valueGetter() {
       var msgWindow=window.open("")
       for (var i = 0; i < newWindow.document.valueTest.elements.length; i++) {
          msgWindow.document.write(newWindow.document.valueTest.elements[i].name + "<BR>")
       }
    }
    
    In the following example, the first statement creates a window called netscapeWin. The second statement displays the value "netscapeHomePage" in the alert dialog box, because "netscapeHomePage" is the value of the windowName argument of netscapeWin.
    netscapeWin=window.open("http://www.netscape.com", "netscapeHomePage")
    
    alert(netscapeWin.name)
    

    See also

    For button, reset, and submit:

  • value property

    options property

    An array corresponding to options in a select object (<OPTION> tags) in source order. See select object.


    parent property

    The parent property is a synonym for a window whose frameset contains the current frame.

    Syntax

    1. parent.propertyName
    2. parent.methodName
    3. top.frameName
    4. top.frames[index]
    

    propertyName is the defaultStatus, status, length, name, or parent property when the calling parent refers to a window object.
    propertyName is the length, name, or parent property when the calling parent refers to a frame object.
    methodName is any method associated with the window object.
    frameName and frames[index] are ways to refer to frames.

    Description

    The parent property refers to the <FRAMESET> window of a frame. Child frames within a frameset refer to sibling frames by using "parent" in place of the window name as follows: parent.frameName or parent.frames[index]. For example, if the fourth frame in a set has NAME="homeFrame", sibling frames can refer to that frame using parent.homeFrame or parent.frames[3].

    You can use parent.parent to refer to the "grandparent" frame or window when a <FRAMESET> tag is nested within a child frame.

    The parent property is read-only. The value of the parent property is

         <object nameAttribute>
    where nameAttribute is the NAME attribute if the parent is a frame, or an internal reference if the parent is a window.

    Property of

    frame, window

    Examples

    See the examples for the frame object.


    pathname property

    A string specifying the url-path portion of the URL.

    Syntax

    location.pathname

    Description

    The pathname property specifies a portion of the URL. The pathname supplies the details of how the specified resource can be accessed.

    You can set the pathname property at any time, although it is safer to set the href property to change a location. If the pathname that you specify cannot be found in the current location, you will get an error.

    See Section 3.1 of RFC 1738 for complete information about the pathname.

    Property of

    link, location

    Examples

    See the examples for the href property.

    See also

  • hash, host, hostname, href, port, protocol, search properties

    PI property

    The ratio of the circumference of a circle to its diameter, approximately 3.14159.

    Syntax

    Math.PI

    Description

    Because PI is a constant, it is a read-only property of Math.

    Property of

    Math

    Examples

    The following example displays the value of pi:

    document.write("The value of pi is " + Math.PI)

    See also

  • E, LN2, LN10, LOG2E, LOG10E, SQRT1_2, SQRT2 properties

    port property

    A string specifying the communications port that the server uses for communications.

    Syntax

    location.port

    Description

    The port property specifies a portion of the URL. The port property is a substring of the host property. The host property is the concatenation of the hostname and port properties, separated by a colon. When the port property is not defined, the host property is the same as the hostname property.

    You can set the port property at any time, although it is safer to set the href property to change a location. If the port that you specify cannot be found in the current location, you will get an error. If the port property is not specified, it defaults to 80 on the server.

    See Section 3.1 of RFC 1738 for complete information about the port.

    Property of

    link, location

    Examples

    See the examples for the href property.

    See also

  • hash, host, hostname, href, pathname, protocol, search properties

    protocol property

    A string specifying the beginning of the URL, up to and including the first colon.

    Syntax

    location.protocol

    Description

    The protocol property specifies a portion of the URL. The protocol indicates the access method of the URL. For example, a protocol of "http:" specifies Hypertext Transfer Protocol, and a protocol of "javascript:" specifies JavaScript code.

    You can set the protocol property at any time, although it is safer to set the href property to change a location. If the protocol that you specify cannot be found in the current location, you will get an error.

    The protocol property represents the scheme name of the URL. See Section 2.1 of RFC 1738 for complete information about the protocol.

    Property of

    link, location

    Examples

    See the examples for the href property.

    See also

  • hash, host, hostname, href, pathname, port, search properties

    referrer property

    Specifies the URL of the calling document when a user clicks a link.

    Syntax

    document.referrer

    Description

    When a user navigates to a destination document by clicking a link object on a source document, the referrer property contains the URL of the source document. Evaluate the referrer property from the destination document.

    referrer is a read-only property.

    Property of

    document

    Examples

    In the following example, the getReferrer() function is called from the destination document. It returns the URL of the source document.

    function getReferrer() {
       return document.referrer
    }
    

    search property

    A string beginning with a question mark that specifies any query information in the URL.

    Syntax

    location.search

    Description

    The search property specifies a portion of the URL.

    You can set the search property at any time, although it is safer to set the href property to change a location. If the search that you specify cannot be found in the current location, you will get an error.

    See Section 3.3 of RFC 1738 for complete information about the search.

    Property of

    link, location

    Examples

    In the following example, the window.open statement creates a window called newWindow and loads the specified URL into it. The document.write statements display all the properties of newWindow.location in a window called msgWindow.

    newWindow=window.open
       ("http://guide-p.infoseek.com/WW/NS/Titles?qt=RFC+1738+&col=WW")
    
    msgWindow.document.write("newWindow.location.href = " +
       newWindow.location.href + "<P>")
    msgWindow.document.write("newWindow.location.protocol = " +
       newWindow.location.protocol + "<P>")
    msgWindow.document.write("newWindow.location.host = " +
       newWindow.location.host + "<P>")
    msgWindow.document.write("newWindow.location.hostName = " +
       newWindow.location.hostName + "<P>")
    msgWindow.document.write("newWindow.location.port = " +
       newWindow.location.port + "<P>")
    msgWindow.document.write("newWindow.location.pathname = " +
       newWindow.location.pathname + "<P>")
    msgWindow.document.write("newWindow.location.search = " +
       newWindow.location.search + "<P>")
    msgWindow.document.write("newWindow.location.hash = " +
       newWindow.location.hash + "<P>")
    msgWindow.document.close()
    

    The previous example displays the following output:

    newWindow.location.href =
       http://guide-p.infoseek.com/WW/NS/Titles?qt=RFC+1738+&col=WW
    newWindow.location.protocol = http:
    newWindow.location.host = guide-p.infoseek.com
    newWindow.location.hostName = guide-p.infoseek.com
    newWindow.location.port =
    newWindow.location.pathname = /WW/NS/Titles
    newWindow.location.search = ?qt=RFC+1738+&col=WW
    newWindow.location.hash =
    

    See also

  • hash, host, hostname, href, pathname, port, protocol properties

    selected property

    A Boolean value specifying the current selection state of an option in a select object.

    Syntax

    selectName.options[index].selected

    selectName is either the value of the NAME attribute of a select object or an element in the elements array.
    index is an integer representing an option in a select object.

    Description

    If an option in a select object is selected, the value of its selected property is true; otherwise, it is false.

    You can set the selected property at any time. The display of the select object updates immediately when you set the selected property.

    In general, the selected property is more useful than the selectedIndex property for select objects that are created with the MULTIPLE attribute. With the selected property, you can evaluate every option in the options array to determine multiple selections, and you can select individual options without clearing the selection of other options.

    Property of

    options array

    Examples

    See the examples for the defaultSelected property.

    See also

  • defaultSelected, index, selectedIndex properties

    selectedIndex property

    An integer specifying the index of the selected option in a select object.

    Syntax

    1. selectName.selectedIndex
    2. selectName.options.selectedIndex
    

    selectName is either the value of the NAME attribute of a select object or an element in the elements array.

    Description

    Options in a select object are indexed in the order in which they are defined, starting with an index of 0. You can set the selectedIndex property at any time. The display of the select object updates immediately when you set the selectedIndex property. Both forms of the syntax specify the same value.

    In general, the selectedIndex property is more useful for select objects that are created without the MULTIPLE attribute. If you evaluate selectedIndex when multiple options are selected, the selectedIndex property specifies the index of the first option only. Setting selectedIndex clears any other options that are selected in the select object.

    The selected property of the select object's options array is more useful for select objects that are created with the MULTIPLE attribute. With the selected property, you can evaluate every option in the options array to determine multiple selections, and you can select individual options without clearing the selection of other options.

    Property of

  • select
  • options array

    Examples

    In the following example, the getSelectedIndex() function returns the selected index in the musicType select object:

    function getSelectedIndex() {
       return document.musicForm.musicType.selectedIndex
    }
    
    The previous example assumes that the select object is similar to the following:
    <SELECT NAME="musicType">
       <OPTION SELECTED> R&B
       <OPTION> Jazz
       <OPTION> Blues
       <OPTION> New Age
    </SELECT>
    

    See also

  • defaultSelected, index, selected properties

    self property

    The self property is a synonym for the current window or frame.

    Syntax

    1. self.propertyName
    2. self.methodName
    

    propertyName is the defaultStatus, status, length, or name property when self refers to a window object.
    propertyName is the length or name property when self refers to a frame object.
    methodName is any method associated with the window object.

    Description

    The self property refers to the current window or frame.

    Use the self property to disambiguate a window property from a form or form element of the same name. You can also use the self property to make your code more readable.

    The self property is read-only. The value of the self property is

         <object nameAttribute>
    where nameAttribute is the NAME attribute if self refers to a frame, or an internal reference if self refers to a window.

    Property of

    frame, window

    Examples

    In the following example, self.status is used to set the status property of the current window. This usage disambiguates the status property of the current window from a form or form element called "status" within the current window.

    <A HREF="" onClick="this.href=pickRandomURL()" onMouseOver="self.status='Pick a random URL' ; return true"> Go!</A>

    See also

  • window property

    SQRT1_2 property

    The square root of one-half; equivalently, one over the square root of two, approximately 0.707.

    Syntax

    Math.SQRT1_2

    Description

    Because SQRT1_2 is a constant, it is a read-only property of Math.

    Property of

    Math

    Examples

    The following example displays 1 over the square root of 2:

    document.write("1 over the square root of 2 is " + Math.SQRT1_2)

    See also

  • E, LN2, LN10, LOG2E, LOG10E, PI, SQRT2 properties

    SQRT2 property

    The square root of two, approximately 1.414.

    Syntax

    Math.SQRT2

    Description

    Because SQRT2 is a constant, it is a read-only property of Math.

    Property of

    Math

    Examples

    The following example displays the square root of 2:

    document.write("The square root of 2 is " + Math.SQRT2)

    See also

  • E, LN2, LN10, LOG2E, LOG10E, PI, SQRT1_2 properties

    status property

    Specifies a priority or transient message in the status bar at the bottom of the window, such as the message that appears when a mouseOver event occurs over an anchor.

    Syntax

    windowReference.status

    windowReference is a valid way of referring to a window, as described in the window object.

    Description

    Do not confuse the status property with the defaultStatus property. The defaultStatus property reflects the default message displayed in the status bar.

    You can set the status property at any time. You must return true if you want to set the status property in the onMouseOver event handler.

    Property of

    window

    Examples

    Suppose you have created a JavaScript function called pickRandomURL() that lets you select a URL at random. You can use the onClick event handler of an anchor to specify a value for the HREF attribute of the anchor dynamically, and the onMouseOver event handler to specify a custom message for the window in the status property:

    <A HREF="" onClick="this.href=pickRandomURL()" onMouseOver="self.status='Pick a random URL'; return true"> Go!</A>

    In the above example, the status property of the window is assigned to the window's self property, as self.status. As this example shows, you must return true to set the status property in the onMouseOver event handler.

    See also

  • defaultStatus property

    target property

    For form, a string specifying the name of the window that responses go to after a form has been submitted. For link, a string specifying the name of the window that displays the content of a clicked hypertext link.

    Syntax

    1. formName.target
    2. linkName.target
    

    formName is either the name of a form or an element in the forms array.
    linkName is an element in the links array.

    Description

    The target property initially reflects the TARGET attribute of the <FORM> and <A> tags; however, setting target overrides these attributes.

    The target property cannot be assigned the value of a JavaScript expression or variable.

    You can set the target property at any time.

    Certain values of the target property may require specific values for other form properties. See RFC 1867 for more information.

    Property of

    form, link, location

    Examples

    The following example specifies that responses to the musicInfo form are displayed in the "msgWindow" window:

    document.musicInfo.target="msgWindow"

    See also

    For form:

  • action, encoding, method properties

    text property

    A string specifying the text that follows an <OPTION> tag in a select object.

    Syntax

    selectName.options[index].text

    selectName is either the value of the NAME attribute of a select object or an element in the elements array.
    index is an integer representing an option in a select object.

    Description

    The text property initially reflects the text that follows an <OPTION> tag in a select object.

    You can set the text property at any time; however, the following effects result:

  • The value of the property changes.
  • The text displayed by the option in the select object does not change.

    Be careful if you change the text property. If you evaluate the property after you change it, the property contains the new value, not the value that is displayed onscreen.

    Property of

    options array

    Examples

    In the following example, the getChoice() function returns the value of the text property for the selected option. The for loop evaluates every option in the musicType select object. The if statement finds the option that is selected.

    function getChoice() {
       for (var i = 0; i < document.musicForm.musicType.length; i++) {
          if (document.musicForm.musicType.options[i].selected == true) {
             return document.musicForm.musicType.options[i].text
          }
       }
       return null
    }
    
    The previous example assumes that the select object is similar to the following:
    <SELECT NAME="musicType">
       <OPTION SELECTED> R&B
       <OPTION> Jazz
       <OPTION> Blues
       <OPTION> New Age
    </SELECT>
    

    title property

    A string representing the title of a document.

    Syntax

    document.title

    Description

    The title property is a reflection of the value specified within the <TITLE> and </TITLE> tags. If a document does not have a title, the title property is null.

    title is a read-only property.

    Property of

    document

    Examples

    In the following example, the value of the title property is assigned to a variable called docTitle:

    var newWindow = window.open("http://www.netscape.com")
    var docTitle = newWindow.document.title
    

    top property

    The top property is a synonym for the top-most Navigator window, which is a "document window" or "Web Browser window."

    Syntax

    1. top.propertyName
    2. top.methodName
    3. top.frameName
    4. top.frames[index]
    

    propertyName is defaultStatus, status, or length.
    methodName is any method associated with the window object.
    frameName and frames[index] are ways to refer to frames.

    Description

    The top property refers to the top-most window that contains frames or nested framesets. Use the top property to refer to this ancestor window.

    The top property is read-only. The value of the top property is

         <object objectReference>
    where objectReference is an internal reference.

    Property of

    window

    Examples

    The statement top.close() closes the top-most ancestor window.

    The statement top.length specifies the number of frames contained within the top-most ancestor window. When the top-most ancestor is defined as follows, top.length returns 3:

    <FRAMESET COLS="30%,40%,30%">
    <FRAME SRC=child1.htm NAME="childFrame1">
    <FRAME SRC=child2.htm NAME="childFrame2">
    <FRAME SRC=child3.htm NAME="childFrame3">
    </FRAMESET>
    

    The following example sets the background color of a frame called myFrame to red. myFrame is a child of the top-most ancestor window.

    top.myFrame.document.bgColor="red"
    

    userAgent property

    A string representing the value of the user-agent header sent in the HTTP protocol from client to server.

    Syntax

    navigator.userAgent

    Description

    Servers use the value sent in the user-agent header to identify the client.

    userAgent is a read-only property.

    Property of

    navigator

    Examples

    The following example displays userAgent information for the Navigator:

    document.write("The value of navigator.userAgent is " +
       navigator.userAgent)

    For Navigator 2.0, this displays the following:

    The value of navigator.userAgent is Mozilla/2.0 (Win16; I)

    See also

  • appName, appVersion, appCodeName properties

    value property

    A string that is related to the VALUE attribute of its object.

    Syntax

    1. objectName.value
    2. radioName[index].value
    3. selectName.options.[index].value
    

    objectName is either the value of the NAME attribute of a hidden, password, text, textarea, button, reset, submit or checkbox object or an element in the elements array.
    radioName is the value of the NAME attribute of a radio object.
    selectName is either the value of the NAME attribute of a select object or an element in the elements array.
    index is an integer representing a radio button in a radio object or an option in a select object.

    Description

    The value property differs for every object.

    hidden, text, and textarea objects

    The value property is a string that initially reflects the VALUE attribute. This string is displayed in the text and textarea fields. The value of this property changes when a user or a program modifies the field.

    You can set the value property at any time. The display of the text and textarea objects updates immediately when you set the value property.

    password object

    The value property is a string that initially reflects the VALUE attribute. This string is represented by asterisks in the password object field. The value of this property changes when a user or a program modifies the field, but the value is always displayed as asterisks.

    If you programatically set the value property and then evaluate it, JavaScript returns the current value. If a user interactively modifies the value in the password field, you cannot evaluate it accurately for security reasons.

    button, reset, and submit objects

    When a VALUE attribute is specified in HTML, the value property is a string that reflects it. This string is displayed on the face of the button.

    When a VALUE attribute is not specified in HTML, the value property differs for each object:

  • For button, it is an empty string
  • For reset, it is the string "Reset"
  • For submit, it is the string "Submit Query"

    These strings are displayed on the faces of the buttons.

    value is a read-only property.

    Do not confuse the value property with the name property. The name property is not displayed onscreen; it is used to reference the objects programatically.

    options array

    The value property is a string that initially reflects the VALUE attribute. The value of this property can change when a program modifies it. The value property is not displayed onscreen, but is returned to the server if the option is selected.

    You can set the value property at any time.

    Do not confuse the value property with the selection state of the select object or the text that is displayed as an option. The selected and selectedIndex properties determine which options are selected, and the defaultSelected property determines the default selection state. The text that is displayed in each option is specified by its text property.

    checkbox and radio objects

    When a VALUE attribute is specified in HTML, the value property is a string that reflects it. When a VALUE attribute is not specified in HTML, the value property is a string that evaluates to "on". The value property is not displayed onscreen, but is returned to the server if the radio button or checkbox is selected.

    You can set the value property at any time.

    Do not confuse the value property with the selection state of the object or the text that is displayed next to each checkbox and radio button. The checked property determines the selection state of the object, and the defaultChecked property determines the default selection state. The text that is displayed is specified following the <INPUT TYPE="checkbox"> or the <INPUT TYPE="radio"> tag.

    Property of

  • button, checkbox, hidden, password, radio, reset, submit, text, textarea objects
  • options array

    Examples

    The following function evaluates the value property of a group of buttons and displays it in the msgWindow window:

    function valueGetter() {
       var msgWindow=window.open("")
       msgWindow.document.write("submitButton.value is " +
          document.valueTest.submitButton.value + "<BR>")
       msgWindow.document.write("resetButton.value is " +
          document.valueTest.resetButton.value + "<BR>")
       msgWindow.document.write("helpButton.value is " +
          document.valueTest.helpButton.value + "<BR>")
       msgWindow.document.close()
    }
    

    This example displays the following values:

    Query Submit
    Reset
    Help
    

    The previous example assumes the buttons have been defined as follows

    <INPUT TYPE=submit NAME="submitButton">
    <INPUT TYPE=reset NAME="resetButton">
    <INPUT TYPE=button NAME="helpButton" VALUE="Help">
    

    The following function evaluates the value property of a group of radio buttons and displays it in the msgWindow window:

    function valueGetter() {
       var msgWindow=window.open("")
       for (var i = 0; i < document.valueTest.radioObj.length; i++) {
           msgWindow.document.write
              ("The value of radioObj[" + i + "] is " +
              document.valueTest.radioObj[i].value +"<BR>")
       }
       msgWindow.document.close()
    }
    

    This example displays the following values:

    on
    on
    on
    on
    

    The previous example assumes the buttons have been defined as follows

    <BR><INPUT TYPE="radio" NAME="radioObj">R&B
    <BR><INPUT TYPE="radio" NAME="radioObj" CHECKED>Soul
    <BR><INPUT TYPE="radio" NAME="radioObj">Rock and Roll
    <BR><INPUT TYPE="radio" NAME="radioObj">Blues
    

    See also

    For hidden, password, text, and textarea:

  • defaultValue property

    For button, reset, and submit:

  • name property

    For options array:

  • defaultSelected, selected, selectedIndex, text properties

    For checkbox and radio:

  • checked, defaultChecked properties

    vlinkColor property

    A string specifying the color of visited links.

    Syntax

    document.vlinkColor

    Description

    The vlinkColor property is expressed as a hexadecimal RGB triplet or as one of the string literals listed in Color Values. This property is the JavaScript reflection of the VLINK attribute of the <BODY> tag. The default value of this property is set by the user on the Colors tab of the Preferences dialog box, which is displayed by choosing General Preferences from the Options menu. You cannot set this property after the HTML source has been through layout.

    If you express the color as a hexadecimal RGB triplet, you must use the format rrggbb. For example, the hexadecimal RGB values for salmon are red=FA, green=80, and blue=72, so the RGB triplet for salmon is "FA8072".

    Property of

    document

    Examples

    The following example sets the color of visited links to aqua using a string literal:

    document.vlinkColor="aqua"
    

    The following example sets the color of active links to aqua using a hexadecimal triplet:

    document.vlinkColor="00FFFF"
    

    See also

  • alinkColor, bgColor, fgColor, and linkColor properties

    window property

    The window property is a synonym for the current window or frame.

    Syntax

    1. window.propertyName
    2. window.methodName
    

    propertyName is the defaultStatus, status, length, or name property when the calling window refers to a window object.
    propertyName is the length or name property when the calling window refers to a frame object.
    methodName is any method associated with the window object.

    Description

    The window property refers to the current window or frame.

    Although you can use the window property as a synonym for the current frame, your code is more readable if you use the self property. For example, window.name and self.name both specify the name of the current frame, but self.name is easier to understand.

    Use the window property to disambiguate a property of the window object from a form or form element of the same name. You can also use the window property to make your code more readable.

    The window property is read-only. The value of the window property is

         <object nameAttribute>
    where nameAttribute is the NAME attribute if window refers to a frame, or an internal reference if window refers to a window.

    Property of

    frame, window

    Examples

    In the following example, window.status is used to set the status property of the current window. This usage disambiguates the status property of the current window from a form called "status" within the current window.

    <A HREF="" onClick="this.href=pickRandomURL()" onMouseOver="window.status='Pick a random URL' ; return true"> Go!</A>

    See also

  • self property