hash property

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

Syntax

1. links[index].hash
2. location.hash

index is an integer representing a link object.

Property of

link, location

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.

Examples

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

See also

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

    hidden object

    A text object that is suppressed from form display on an HTML form. A hidden object is used for passing name/value pairs when a form submits.

    Syntax

    To define a hidden object:

    <INPUT
       TYPE="hidden"
       NAME="hiddenName"
       [VALUE="textValue"]>
    
    NAME="hiddenName" specifies the name of the hidden object. You can access this value using the name property.
    VALUE="textValue" specifies the initial value of the hidden object.

    To use a hidden object's properties:

    1. hiddenName.propertyName
    2. formName.elements[index].propertyName
    
    hiddenName is the value of the NAME attribute of a hidden object.
    formName is either the value of the NAME attribute of a form object or an element in the forms array.
    index is an integer representing a hidden object on a form.
    propertyName is one of the properties listed below.

    Property of

  • form

    Description

    A hidden object is a form element and must be defined within a <FORM> tag.

    A hidden object cannot be seen or modified by a user, but you can programatically change the value of the object by changing its value property. You can use hidden objects for client/server communication.

    Properties

  • name reflects the NAME attribute
  • value reflects the current value of the hidden object

    Methods

  • None.

    Event handlers

  • None.

    Examples

    The following example uses a hidden object to store the value of the last object the user clicked. The form contains a "Display hidden value" button that the user can click to display the value of the hidden object in an Alert dialog box. <HTML> <HEAD> <TITLE>Hidden object example</TITLE> </HEAD> <BODY> <B>Click some of these objects, then click the "Display value" button <BR>to see the value of the last object clicked.</B> <FORM NAME="form1"> <INPUT TYPE="hidden" NAME="hiddenObject" VALUE="None"> <P> <INPUT TYPE="button" VALUE="Click me" NAME="button1" onClick="document.form1.hiddenObject.value=this.value"> <P> <INPUT TYPE="radio" NAME="musicChoice" VALUE="soul-and-r&b" onClick="document.form1.hiddenObject.value=this.value"> Soul and R&B <INPUT TYPE="radio" NAME="musicChoice" VALUE="jazz" onClick="document.form1.hiddenObject.value=this.value"> Jazz <INPUT TYPE="radio" NAME="musicChoice" VALUE="classical" onClick="document.form1.hiddenObject.value=this.value"> Classical <P> <SELECT NAME="music_type_single" onFocus="document.form1.hiddenObject.value=this.options[this.selectedIndex].text"> <OPTION SELECTED> Red <OPTION> Orange <OPTION> Yellow </SELECT> <P><INPUT TYPE="button" VALUE="Display hidden value" NAME="button2" onClick="alert('Last object clicked: ' + document.form1.hiddenObject.value)"> </FORM> </BODY> </HTML>

    See also

  • cookie property

    history object

    Contains information on the URLs that the client has visited within a window. This information is stored in a history list, and is accessible through the Navigator's Go menu.

    Syntax

    To use a history object:

    1. history.propertyName
    2. history.methodName(parameters)
    
    propertyName is one of the properties listed below.
    methodName is one of the methods listed below.

    Property of

  • document

    Description

    The history object is a linked list of URLs the user has visited, as shown in the Navigator's Go menu.

    Properties

  • length reflects the number of entries in the history object

    Methods

  • back
  • forward
  • go

    Event handlers

  • None.

    Examples

    Example 1. The following example goes to the URL the user visited three clicks ago in the current window.

    history.go(-3)

    Example 2. You can use the history object with a specific window or frame. The following example causes window2 to go back one item in its window (or session) history:

    window2.history.back()

    Example 3. The following example causes the second frame in a frameset to go back one item:

    parent.frames[1].history.back()

    Example 4. The following example causes the frame named frame1 in a frameset to go back one item:

    parent.frame1.history.back()

    Example 5. The following example causes the frame named frame2 in window2 to go back one item:

    window2.frame2.history.back()

    See also

  • location object

    host property

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

    Syntax

    1. links[index].host
    2. location.host
    

    index is an integer representing a link object.

    Property of

    link, location

    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.

    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

    1. links[index].hostname
    2. location.hostname
    

    index is an integer representing a link object.

    Property of

    link, location

    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.

    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

    1. links[index].href
    2. location.href
    

    index is an integer representing a link object.

    Property of

    link, location

    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.

    Omitting a property name from the location object is equivalent to specifying location.href. For example, the following two statements are equivalent and set the URL of the current window to the Netscape home page:

    window.location.href="http://www.netscape.com/" window.location="http://www.netscape.com/"

    See RFC 1738 for complete information about the URL.

    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.

    Property of

    options array

    Description

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

    See also

  • defaultSelected, selected, selectedIndex properties

    indexOf method

    Returns the index within the calling string object of the first occurrence of the specified value, starting the search at fromIndex.

    Syntax

    stringName.indexOf(searchValue, [fromIndex])

    stringName is any string or a property of an existing object.
    searchValue is a string or a property of an existing object, representing the value to search for.
    fromIndex is the location within the calling string to start the search from. It can be any integer from 0 to stringName.length - 1 or a property of an existing object.

    Method of

    string

    Description

    Characters in a string are indexed from left to right. The index of the first character is 0, and the index of the last character is stringName.length - 1.

    If you do not specify a value for fromIndex, JavaScript assumes 0 by default. If searchValue is not found, JavaScript returns -1.

    Examples

    The following example uses indexOf and lastIndexOf to locate values in the string "Brave new world".
    var anyString="Brave new world"
    
    //Displays 8
    document.write("<P>The index of the first w from the beginning is " +
       anyString.indexOf("w"))
    //Displays 10
    document.write("<P>The index of the first w from the end is " +
       anyString.lastIndexOf("w"))
    //Displays 6
    document.write("<P>The index of 'new' from the beginning is " +
       anyString.indexOf("new"))
    //Displays 6
    document.write("<P>The index of 'new' from the end is " +
       anyString.lastIndexOf("new"))
    

    See also

  • charAt, lastIndexOf methods

    isNaN function

    On Unix platforms, evaluates an argument to determine if it is "NaN" (not a number).

    Syntax

    isNaN(testValue)

    testValue is the value you want to evaluate.

    Description

    The isNaN function is a built-in JavaScript function. It is not a method associated with any object, but is part of the language itself. isNaN is available on Unix platforms only.

    On all platforms except Windows, the parseFloat and parseInt functions return "NaN" when they evaluate a value that is not a number. The "NaN" value is not a number in any radix. You can call the isNaN function to determine if the result of parseFloat or parseInt is "NaN". If "NaN" is passed on to arithmetic operations, the operation results will also be "NaN".

    The isNaN function returns true or false.

    Examples

    The following example evaluates floatValue to determine if it is a number, then calls a procedure accordingly.

    floatValue=parseFloat(toFloat)
    
    if isNaN(floatValue) {
       notFloat()
    } else {
       isFloat()
    }
    

    See also

  • parseFloat, parseInt functions

    italics method

    Causes a string to be italicized as if it were in an <I> tag.

    Syntax

    stringName.italics()

    stringName is any string or a property of an existing object.

    Method of

    string

    Description

    Use the italics method with the write or writeln methods to format and display a string in a document.

    Examples

    The following example uses string methods to change the formatting of a string:
    var worldString="Hello, world"
    
    document.write(worldString.blink())
    document.write("<P>" + worldString.bold())
    document.write("<P>" + worldString.italics())
    document.write("<P>" + worldString.strike())
    

    The previous example produces the same output as the following HTML:

    <BLINK>Hello, world</BLINK>
    <P><B>Hello, world</B>
    <P><I>Hello, world</I>
    <P><STRIKE>Hello, world</STRIKE>
    

    See also

  • blink, bold, strike methods

    lastIndexOf method

    Returns the index within the calling string object of the last occurrence of the specified value. The calling string is searched backwards, starting at fromIndex.

    Syntax

    stringName.lastIndexOf(searchValue, [fromIndex])

    stringName is any string or a property of an existing object.
    searchValue is a string or a property of an existing object, representing the value to search for.
    fromIndex is the location within the calling string to start the search from. It can be any integer from 0 to stringName.length - 1 or a property of an existing object.

    Method of

    string

    Description

    Characters in a string are indexed from left to right. The index of the first character is 0, and the index of the last character is stringName.length - 1.

    If you do not specify a value for fromIndex, JavaScript assumes stringName.length - 1 (the end of the string) by default. If searchValue is not found, JavaScript returns -1.

    Examples

    The following example uses indexOf and lastIndexOf to locate values in the string "Brave new world".
    var anyString="Brave new world"
    
    //Displays 8
    document.write("<P>The index of the first w from the beginning is " +
       anyString.indexOf("w"))
    //Displays 10
    document.write("<P>The index of the first w from the end is " +
       anyString.lastIndexOf("w"))
    //Displays 6
    document.write("<P>The index of 'new' from the beginning is " +
       anyString.indexOf("new"))
    //Displays 6
    document.write("<P>The index of 'new' from the end is " +
       anyString.lastIndexOf("new"))
    

    See also

  • charAt, indexOf methods

    lastModified property

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

    Syntax

    document.lastModified

    Property of

    document

    Description

    lastModified is a read-only property.

    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.

    Property of

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

    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.

    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)
    

    link method

    Creates an HTML hypertext link that jumps to another URL.

    Syntax

    linkText.link(hrefAttribute)

    linkText is any string or a property of an existing object.
    hrefAttribute is any string or a property of an existing object.

    Method of

    string

    Description

    Use the link method with the write or writeln methods to programatically create and display a hypertext link in a document. Create the link with the link method, then call write or writeln to display the link in a document.

    In the syntax, the linkText string represents the literal text that you want the user to see. The hrefAttribute string represents the HREF attribute of the <A> tag, and it should be a valid URL. Each section of a URL contains different information. See the location object for a description of the URL components.

    Links created with the link method become elements in the links array. See the link object for information about the links array.

    Examples

    The following example displays the word "Netscape" as a hypertext link that returns the user to the Netscape home page:

    var hotText="Netscape"
    var URL="http://www.netscape.com"
    
    document.open()
    document.write("Click to return to " + hotText.link(URL))
    document.close()
    

    The previous example produces the same output as the following HTML:

    Click to return to <A HREF="http://www.netscape.com">Netscape</A>

    See also

  • anchor method

    link object (links array)

    A piece of text or an image identified as a hypertext link. When the user clicks the link text, the link hypertext reference is loaded into its target window.

    Syntax

    To define a link, use standard HTML syntax with the addition of the onClick and onMouseOver event handlers:

    <A HREF=locationOrURL
       [NAME="anchorName"]
       [TARGET="windowName"]
       [onClick="handlerText"]
       [onMouseOver="handlerText"]>
       linkText
    </A>
    
    HREF=locationOrURL identifies a destination anchor or URL. See the location object for a description of the URL components.
    NAME="anchorName" specifies a tag that becomes an available hypertext target within the current document. If this attribute is present, the link object is also an anchor object. See anchor for details.
    TARGET="windowName" specifies the window that the link is loaded into. windowName can be an existing window; it can be a frame name specified in a <FRAMESET> tag; or it can be one of the literal frame names _top, _parent, _self, or _blank; it cannot be a JavaScript expression (for example, it cannot be parent.frameName or windowName.frameName).
    linkText is rendered as a hypertext link to the URL.

    You can also define a link using the link method.

    To use a link object's properties:

    document.links[index].propertyName
    
    index is an integer representing a link object.
    propertyName is one of the properties listed below.

    Property of

  • document

    Description

    Each link object is a location object and has the same properties as a location object.

    If a link object is also an anchor object, the object has entries in both the anchors and links arrays.

    When a user clicks a link object and navigates to the destination document (specified by HREF=locationOrURL), the destination document's referrer property contains the URL of the source document. Evaluate the referrer property from the destination document.

    The links array

    You can reference the link objects in your code by using the links array. This array contains an entry for each link object (<A HREF=""> tag) in a document in source order. For example, if a document contains three link objects, these links are reflected as document.links[0], document.links[1], and document.links[2].

    To use the links array:

    1. document.links[index]
    2. document.links.length
    

    index is an integer representing a link in a document.

    To obtain the number of links in a document, use the length property: document.links.length.

    Elements in the links array are read-only. For example, the statement document.links[0]="link1" has no effect.

    Properties

    The link object has the following properties:

  • hash specifies an anchor name in the URL
  • host specifies the hostname:port portion of the URL
  • hostname specifies the host and domain name, or IP address, of a network host
  • href specifies the entire URL
  • pathname specifies the url-path portion of the URL
  • port specifies the communications port that the server uses for communications
  • protocol specifies the beginning of the URL, including the colon
  • search specifies a query
  • target reflects the TARGET attribute

    The links array has the following properties:

  • length reflects the number of links in a document

    Methods

  • None.

    Event handlers

  • onClick
  • onMouseOver

    Examples

    Example 1. The following example creates a hypertext link to an anchor named javascript_intro.

    <A HREF="#javascript_intro">Introduction to JavaScript</A>

    Example 2. The following example creates a hypertext link to an anchor named numbers in the file DOC3.HTML in the window window2. If window2 does not exist, it is created.

    <LI><A HREF=doc3.html#numbers TARGET="window2">Numbers</A>

    Example 3. The following example takes the user back x entries in the history list:

    <A HREF="javascript:history.go(-1 * x)">Click here</A>

    Example 4. The following example creates a hypertext link to a URL. A set of radio buttons lets the user choose between three URLs. The link's onClick event handler sets the URL (the link's href property) based on the selected radio button. The link also has an onMouseOver event handler that changes the window's status property. As the example shows, you must return true to set the window.status property in the onMouseOver event handler.

    <SCRIPT> var destHREF="'http://www.netscape.com/" </SCRIPT> <FORM NAME="form1"> <B>Choose a destination from the following list, then click "Click me" below.</B> <BR><INPUT TYPE="radio" NAME="destination" VALUE="netscape" onClick="destHREF='http://www.netscape.com/'"> Netscape home page <BR><INPUT TYPE="radio" NAME="destination" VALUE="sun" onClick="destHREF='http://www.sun.com/'"> Sun home page <BR><INPUT TYPE="radio" NAME="destination" VALUE="rfc1867" onClick="destHREF='http://www.ics.uci.edu/pub/ietf/html/rfc1867.txt'"> RFC 1867 <P><A HREF="" onMouseOver="window.status='Click this if you dare!'; return true" onClick="this.href=destHREF"> <B>Click me</B></A> </FORM>

    Example 5: links array. The following example opens the Netscape home page in the newWindow window. The linkGetter() function uses the links array to display the value of each of its links.

    newWindow=window.open("http://www.netscape.com") function linkGetter() { msgWindow=window.open("") for (var i = 0; i < newWindow.document.links.length; i++) { msgWindow.document.write(newWindow.document.links[i] + "<BR>") } }

    See also

  • anchor object
  • link method

    linkColor property

    A string specifying the color of the document hyperlinks.

    Syntax

    document.linkColor

    Property of

    document

    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".

    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

    Property of

    Math

    Description

    Because LN2 is a constant, it is a read-only 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

    Property of

    Math

    Description

    Because LN10 is a constant, it is a read-only 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 object

    Contains information on the current URL.

    Syntax

    To use a location object:

    [windowReference.]location[.propertyName]
    
    windowReference is a variable windowVar from a window definition (see window object), or one of the synonyms top or parent.
    propertyName is one of the properties listed below. Omitting the property name is equivalent to specifying the href property (the complete URL).

    Property of

  • window

    Description

    The location object represents a complete URL. Each property of the location object represents a different portion of the URL.

    The following diagram of a URL shows the relationships between the location properties:

    protocol//hostname:port pathname search hash

    protocol represents the beginning of the URL, up to and including the first colon.
    hostname represents the host and domain name, or IP address, of a network host.
    port represents the communications port that the server uses for communications.
    pathname represents the url-path portion of the URL.
    search represents any query information in the URL, beginning with a question mark.
    hash represents an anchor name fragment in the URL, beginning with a hash mark (#).

    See the properties (listed below) for details about the different parts of the URL, or the href property for examples.

    The location object has two other properties not shown in the diagram above:

    href represents a complete URL.
    host represents the concatenation hostname:port.

    The location object is contained by the window object and is within its scope. If you reference a location object without specifying a window, the location object represents the current location. If you reference a location object and specify a window name, for example, windowReference.location.propertyName, the location object represents the location of the specified window.

    Do not confuse the location object with the location property of the document 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.href is set to when you load the document, but redirection may change it.

    Syntax for common URL types

    When you specify a URL, you can use standard URL formats and JavaScript statements. The following list shows the syntax for specifying some of the most common types of URLs.
    URL typeProtocolExample
    JavaScript codejavascript:javascript:history.go(-1)
    Navigator infoabout:about:cache
    World Wide Webhttp:http://www.netscape.com/
    Filefile:file:///javascript/methods.html
    FTPftp:ftp://ftp.mine.com/home/mine
    MailTomailto:mailto:info@netscape.com
    Usenetnews:news://news.scruznet.com/comp.lang.javascript
    Gophergopher:gopher.myhost.com

    The javascript: protocol evaluates the expression after the colon (:), if there is one, and loads a page containing the string value of the expression, unless it is undefined. If the expression evaluates to undefined, no new page loads.

    The about: protocol provides information on Navigator and has the following syntax:

    about:[cache|plugins]
    
    about: by itself is the same as choosing About Netscape from the Navigator's Help menu.
    about:cache displays disk cache statistics.
    about:plug-ins displays information about plug-ins you have configured. This is the same as choosing About Plug-ins from the Navigator's Help menu.

    Properties

  • hash specifies an anchor name in the URL
  • host specifies the hostname:port portion of the URL
  • hostname specifies the host and domain name, or IP address, of a network host
  • href specifies the entire URL
  • pathname specifies the url-path portion of the URL
  • port specifies the communications port that the server uses for communications
  • protocol specifies the beginning of the URL, including the colon
  • search specifies a query

    Methods

  • None.

    Event handlers

  • None.

    Examples

    Example 1. The following two statements are equivalent and set the URL of the current window to the Netscape home page:

    window.location.href="http://www.netscape.com/" window.location="http://www.netscape.com/"

    Example 2. The following statement sets the URL of a frame named frame2 to the Sun home page:

    parent.frame2.location.href="http://www.sun.com/"

    See also the example for the anchor object.

    See also

  • history object
  • location property

    location property

    A string specifying the complete URL of the document.

    Syntax

    document.location

    Property of

    document

    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.href is set to when you load the document, but redirection may change it.

    location is a read-only 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

    log method

    Returns the natural logarithm (base e) of a number.

    Syntax

    Math.log(number)
    number is any positive numeric expression or a property of an existing object.

    Method of

    Math

    Description

    If the value of number is outside the suggested range, the return value is always -1.797693134862316e+308.

    Examples

    //Displays the value 2.302585092994046
    document.write("The natural log of 10 is " + Math.log(10))
    
    //Displays the value 0
    document.write("<P>The natural log of 1 is " + Math.log(1))
    
    //Displays the value -1.797693134862316e+308
    //because the argument is out of range
    document.write("<P>The natural log of 0 is " + Math.log(0))
    

    See also

  • exp, pow methods

    LOG2E property

    The base 2 logarithm of e (approximately 1.442).

    Syntax

    Math.LOG2E

    Property of

    Math

    Description

    Because LOG2E is a constant, it is a read-only 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

    Property of

    Math

    Description

    Because LOG10E is a constant, it is a read-only 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