please dont rip this site

[Previous reference file]


 

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
3. areaName.hash

Parameters

index is an integer representing a Link object or the name of a Link object as specified by the NAME attribute.

areaName is the value of the NAME attribute of an Area object.

Property of

Area object (see Link object), Link object, location object

Implemented in

Tainted?

Yes

Description

The hash property specifies a portion of the URL. This property applies to http URLs only.

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.

Setting the hash property navigates to the named anchor without reloading the document. This differs from the way a document is loaded when other location properties are set (see "How documents are loaded when location is set").

In event handlers, you must specify window.location.hash instead of simply using location.hash. Due to the scoping of static objects in JavaScript, a call to location without specifying an object name is equivalent to document.location, which is a synonym for document.URL.

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


height

Property. A string specifying the height of an image in pixels.

Syntax

imageName.height

Parameters

imageName is either the name of an Image object or an element in the images array.

Property of

Image

Implemented in

Navigator 3.0

Tainted?

No

Description

The height property reflects the HEIGHT attribute of the <IMG> tag. For images created with the Image() constructor, the value of the height property is the actual, not the displayed, height of the image.

height is a read-only property.

Examples

The following function displays the values of an image's height, width, hspace, and vspace properties.

function showImageSize(theImage) {
   alert('height=' + theImage.height+
       '; width=' + theImage.width +
       '; hspace=' + theImage.hspace +
       '; vspace=' + theImage.vspace)
}

See also

border, hspace, vspace, width 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.

HTML syntax

To define a Hidden object, use standard HTML syntax:

<INPUT
   TYPE="hidden"
   NAME="hiddenName"
   [VALUE="textValue"]>

HTML attributes

NAME="hiddenName" specifies the name of the Hidden object. You can access this value using the name property, and you can use this name when indexing the elements array.

VALUE="textValue" specifies the initial value of the Hidden object.

Syntax

To use a Hidden object's properties:

1. hiddenName.propertyName
2. formName.elements[index].propertyName

Parameters

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 or the name of a Hidden object as specified by the NAME attribute.

propertyName is one of the properties listed below.

Property of

Form object

Implemented in

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 programmatically change the value of the object by changing its value property. You can use Hidden objects for client/server communication.

Properties

The Hidden object has the following properties:

Property Description
name Reflects the NAME attribute
form property Specifies the form containing the Hidden object
type Reflects the TYPE attribute
value Reflects the current value of the Hidden object

Methods

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 array

Property. An array reflecting all the history entries in a window in source order. See the history object for information.

Tainted?

No


history object

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 Go menu.

Syntax

To use a history object:

1. history.propertyName
2. history.methodName(parameters)
3. [windowReference.]history[index]

Parameters

propertyName is one of the properties listed below.

methodName is one of the methods listed below.

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

index is an integer representing an entry in the history list.

Property of

window object

Implemented in

Description

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

To change a window's current URL without generating a history entry, you can use the replace method. This replaces the current page with a new one without generating a history entry. See the replace method.

The history array

You can reference the history entries by using the history array. This array contains an entry for each history entry in source order; each array entry is a string containing a URL. For example, if the history list contains three named entries, these entries are reflected as history[0], history[1], and history[2].

To use the history array:

1. history[index]
2. history.length

index is an integer representing an entry in the history list.

To obtain the number of entries in the history list, use the length property: history.length.

Elements in the history array are read-only. For example, the statement history[0]="http://home.netscape.com" has no effect.

If you access the history array without specifying an array element, Navigator returns a string of HTML which displays a table of URLs, each of which is a hyperlink.

Properties

The history object has the following properties:

Property Description
current Specifies the URL of the current history entry
length Reflects the number of entries in the history list
next Specifies the URL of the next history entry
previous Specifies the URL of the previous history entry

The history array has the following properties:

Property Description
length Reflects the number of history entries in the window

Methods

The History object has the following methods:

back

eval

forward

go

toString

valueOf

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()

Example 6. The following code determines whether the first entry in the history array contains the string "NETSCAPE". If it does, the function myFunction is called.

if (history[0].indexOf("NETSCAPE") != -1) {
   myFunction(history[0])
}

Example 7. The following example displays the entire history list:

document.writeln("<B>history is</B> " + history)

This code displays output similar to the following:

history is

Welcome to Netscape           http://home.netscape.com/

Sun Microsystems              http://www.sun.com/

SlugVideo at the Dream Inn    http://sapphire.cse.ucsc.edu/SlugVideo/dream-inn.html

Bad Dog Chronicles                 http://www.supernet.net/~dugbrown/

See also

location object, replace method


host

Property. A string specifying the server name, subdomain, and domain name.

Syntax

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

Parameters

index is an integer representing a Link object or the name of a Link object as specified by the NAME attribute.

areaName is the value of the NAME attribute of an Area object.

Property of

Area object (see Link object), Link object, location object

Implemented in

Tainted?

Yes

Description

The host property specifies a portion of a URL. The host property is a substring of the hostname property. The hostname property is the concatenation of the host 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.

In event handlers, you must specify window.location.host instead of simply using location.host. Due to the scoping of static objects in JavaScript, a call to location without specifying an object name is equivalent to document.location, which is a synonym for document.URL.

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 containing the full hostname of the server, including the server name, subdomain, domain, and port number.

Syntax

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

Parameters

index is an integer representing a Link object or the name of a Link object as specified by the NAME attribute.

areaName is the value of the NAME attribute of an Area object.

Property of

Area object (see Link object), Link object, location object

Implemented in

Tainted?

Yes

Description

The hostname property specifies a portion of a URL. The hostname property is the concatenation of the host and port properties, separated by a colon. When the port property is 80 (the default), 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.

In event handlers, you must specify window.location.hostname instead of simply using location.hostname. Due to the scoping of static objects in JavaScript, a call to location without specifying an object name is equivalent to document.location, which is a synonym for document.URL.

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
3. areaName.href

Parameters

index is an integer representing a Link object or the name of a Link object as specified by the NAME attribute.

areaName is the value of the NAME attribute of an Area object.

Property of

Area object (see Link object), Link object, location object

Implemented in

Tainted?

Yes

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://home.netscape.com/"
window.location="http://home.netscape.com/"

In event handlers, you must specify window.location.href instead of simply using location.href. Due to the scoping of static objects in JavaScript, a call to location without specifying an object name is equivalent to document.location, which is a synonym for document.URL.

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.hash = " +
   newWindow.location.hash + "<P>")
msgWindow.document.write("newWindow.location.search = " +
   newWindow.location.search + "<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.hash = #checkbox_object
newWindow.location.search =

See also

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


hspace

Property. A string specifying a margin in pixels between the left and right edges of an image and the surrounding text.

Syntax

imageName.hspace

Parameters

imageName is either the name of an Image object or an element in the images array.

Property of

Image

Implemented in

Navigator 3.0

Tainted?

No

Description

The hspace property reflects the HSPACE attribute of the <IMG> tag. For images created with the Image() constructor, the value of the hspace property is 0.

hspace is a read-only property.

Examples

See the examples for the height property.

See also

border, height, vspace, width properties


Image

Object. An image on an HTML form.

HTML syntax

To define an image, use standard HTML syntax with the addition of JavaScript event handlers:

<IMG
   [NAME="imageName"]
   SRC="Location"
   [LOWSRC="Location"]
   [HEIGHT="Pixels"|"Value"%]
   [WIDTH="Pixels"|"Value"%]
   [HSPACE="Pixels"]
   [VSPACE="Pixels"]
   [BORDER="Pixels"]
   [ALIGN="left"|"right"|
      "top"|"absmiddle"|"absbottom"|
      "texttop"|"middle"|"baseline"|"bottom"]
   [ISMAP]
   [USEMAP="#MapName"]
   [onAbort="handlerText"]
   [onError="handlerText"]
   [onLoad="handlerText"]>

HTML attributes

NAME="imageName" specifies the name of the Image object. You can access this value using the name property, and you can use this name when indexing the images array.

SRC="Location" specifies the URL of the image to be displayed in the document. You can access this value using the src property.

LOWSRC="Location" specifies the URL of a low-resolution version of the image to be displayed in the document. Navigator loads this smaller image and then replaces it with the larger image specified by SRC. You can access this value using the lowsrc property.

HEIGHT="Pixels"|"Value"% specifies the height of the image either in pixels or as a percentage of the window height. If necessary, Navigator scales the image to fit the space specified by this attribute. You can access this value using the height property.

WIDTH="Pixels"|"Value"% specifies the width of the image either in pixels or as a percentage of the window width. If necessary, Navigator scales the image to fit the space specified by this attribute. You can access this value using the width property.

HSPACE="Pixels" specifies a margin in pixels between the left and right edges of the image and the surrounding text. This attribute applies only to images that use "left" or "right" as the value of the ALIGN attribute. You can access this value using the hspace property.

VSPACE="Pixels" specifies a margin in pixels between the top and bottom edges of the image and the surrounding text. This attribute applies only to images that use "left" or "right" as the value of the ALIGN attribute. You can access this value using the vspace property.

BORDER="Pixels" specifies the width, in pixels, of an image border. You can suppress the border by setting its value to 0; however, if you suppress the border of an image that appears within an anchor, users will not see a colored border indicating that the image is a hyperlink. You can access this value using the border property.

ALIGN specifies the alignment of the image in relation to the surrounding text. Images that are aligned as "left" or "right" float into the next available space on the left or right side of the page, and cause text to wrap around them. Other ALIGN values place the image in a line of text and do not cause the text to wrap. If omitted, "bottom" is used.

ISMAP specifies the image as a server-side image map.

USEMAP="#MapName" specifies the image as a client-side image map. This attribute specifies the # symbol followed by the name of the map. For example, USEMAP="#areamap".

Syntax

To create an Image object:

imageName = new Image([width, height])

To use an Image object's properties:

1. imageName.propertyName
2. document.images[index].propertyName
3. formName.elements[index].propertyName

To define an event handler for an Image object created with the Image() constructor:

1. imageName.onabort = handlerFunction
2. imageName.onerror = handlerFunction
3. imageName.onload = handlerFunction

Parameters

imageName is either the name of a new object or a property of an existing object. When using an Image object's properties, imageName is the value of the NAME attribute of an Image object or the imageName specified with the Image() constructor.

width is the image width, in pixels.

height is the image height, in pixels.

formName is either the value of the NAME attribute of a Form object or an element in the forms array.

index, when used with the images array is an integer representing an Image object or the name of an Image object as specified by the NAME attribute. index, when used with the elements array, is an integer representing an Image object on a form.

propertyName is one of the properties listed below.

handlerFunction is the keyword null, the name of a function, or a variable or property that contains null or a valid function reference.

Property of

document

Implemented in

Navigator 3.0

Description

The position and size of an image in a document are set when the document is displayed in Navigator and cannot be changed using JavaScript (the width and height properties are read-only). You can change which image is displayed by setting the src and lowsrc properties. (See the descriptions of src and lowsrc.)

You can use JavaScript to create an animation with an Image object by repeatedly setting the src property, as shown in Example 4 below. JavaScript animation is slower than GIF animation, because with GIF animation the entire animation is in one file; with JavaScript animation, each frame is in a separate file, and each file must be loaded across the network (host contacted and data transferred).

Image objects do not have onClick, onMouseOut, and onMouseOver event handlers. However, if you define an Area object for the image or place the <IMG> tag within a Link object, you can use the Area or Link object's event handlers. See the Link object.

The Image() constructor

The primary use for an Image object created with the Image() constructor is to load an image from the network (and decode it) before it is actually needed for display. Then when you need to display the image within an existing image cell, you can set the src property of the displayed image to the same value as that used for the prefetched image, as follows.

myImage = new Image()
myImage.src = "seaotter.gif"
...
document.images[0].src = myImage.src

The resulting image will be obtained from cache, rather than loaded over the network, assuming that sufficient time has elapsed to load and decode the entire image. You can use this technique to create smooth animations, or you could display one of several images based on form input.

images array ">

The images array

You can reference the images in a document by using the images array. This array contains an entry for each Image object (<IMG> tag) in a document in source order (images created with the Image() constructor are not included in the images array). For example, if a document contains three images, these images are reflected as document.images[0], document.images[1], and document.images[2].

To use the images array:

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

index is an integer representing an image in a document or the name of an Image object as specified by the NAME attribute.

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

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

Properties

The Image object has the following properties:

Property Description
border Reflects the BORDER attribute
complete Boolean value indicating whether Navigator has completed its attempt to load the image
height Reflects the HEIGHT attribute
hspace Reflects the HSPACE attribute
lowsrc Reflects the LOWSRC attribute
name Reflects the NAME attribute
prototype Lets you add a properties to an Image object.
src Reflects the SRC attribute
vspace Reflects the VSPACE attribute
width Reflects the WIDTH attribute

Note

The border, hspace, name, and vspace properties are not meaningful for images created with the Image() constructor.

The images array has the following properties:

Property Description
length Reflects the number of images in a document

Methods

Event handlers

onAbort

onError

onLoad

Examples

Example 1: Create an image with the <IMG> tag. The following code defines an image using the <IMB> tag:

<IMG NAME="aircraft" SRC="f15e.gif" ALIGN="left" VSPACE="10">

The following code refers to the image:

document.aircraft.src='f15e.gif'

When you refer to an image by its name, you must include the form name if the image is on a form. The following code refers to the image if it is on a form:

document.myForm.aircraft.src='f15e.gif'

Example 2: Create an image with the Image() constructor. The following example creates an Image object, myImage, that is 70 pixels wide and 50 pixels high. If the source URL, seaotter.gif, does not have dimensions of 70x50 pixels, it is scaled to that size.

myImage = new Image(70, 50)
myImage.src = "seaotter.gif"

If you omit the width and height arguments from the Image() constructor, myImage is created with dimensions equal to that of the image named in the source URL.

myImage = new Image()
myImage.src = "seaotter.gif"

Example 3: Display an image based on form input. In the following example, the user selects which image is displayed. The user orders a shirt by filling out a form. The image displayed depends on the shirt color and size that the user chooses. All possible image choices are pre-loaded to speed response time. When the user clicks the button to order the shirt, the allShirts function displays the images of all the shirts.

<SCRIPT>
shirts = new Array()
shirts[0] = "R-S"
shirts[1] = "R-M"
shirts[2] = "R-L"
shirts[3] = "W-S"
shirts[4] = "W-M"
shirts[5] = "W-L"
shirts[6] = "B-S"
shirts[7] = "B-M"
shirts[8] = "B-L"

doneThis = 0
shirtImg = new Array()

// Preload shirt images
for(idx=0; idx < 9; idx++) {
   shirtImg[idx] = new Image()
   shirtImg[idx].src = "shirt-" + shirts[idx] + ".gif"
}

function changeShirt(form)
{
   shirtColor = form.color.options[form.color.selectedIndex].text
   shirtSize = form.size.options[form.size.selectedIndex].text

   newSrc = "shirt-" + shirtColor.charAt(0) + "-" + shirtSize.charAt(0) + ".gif"
   document.shirt.src = newSrc
}

function allShirts()
{
   document.shirt.src = shirtImg[doneThis].src
   doneThis++
   if(doneThis != 9)setTimeout("allShirts()", 500)
   else doneThis = 0

   return
}

</SCRIPT>

<FONT SIZE=+2><B>Netscape Polo Shirts!</FONT></B>

<TABLE CELLSPACING=20 BORDER=0>
<TR>
<TD><IMG name="shirt" SRC="shirt-W-L.gif"></TD>

<TD>
<FORM>
<B>Color</B>
<SELECT SIZE=3 NAME="color" onChange="changeShirt(this.form)">
<OPTION> Red
<OPTION SELECTED> White
<OPTION> Blue
</SELECT>

<P>
<B>Size</B>
<SELECT SIZE=3 NAME="size" onChange="changeShirt(this.form)">
<OPTION> Small
<OPTION> Medium
<OPTION SELECTED> Large
</SELECT>

<P><INPUT type="button" name="buy" value="Buy This Shirt!"
   onClick="allShirts()">
</FORM>

</TD>
</TR>
</TABLE>

Example 4: JavaScript animation. The following example uses JavaScript to create an animation with an Image object by repeatedly changing the value the src property. The script begins by preloading the 10 images that make up the animation (image1.gif, image2.gif, image3.gif, and so on). When the Image object is placed on the document with the <IMG> tag, image1.gif is displayed and the onLoad event handler starts the animation by calling the animate function. Notice that the animate function does not call itself after changing the src property of the Image object. This is because when the src property changes, the image's onLoad event handler is triggered and the animate function is called.

<SCRIPT>
delay = 100
imageNum = 1

// Preload animation images
theImages = new Array()
for(i = 1; i < 11; i++) {
   theImages[i] = new Image()
   theImages[i].src = "image" + i + ".gif"
}

function animate() {
   document.animation.src = theImages[imageNum].src
   imageNum++
   if(imageNum > 10) {
      imageNum = 1
   }
}

function slower() {
   delay+=10
   if(delay > 4000) delay = 4000
}

function faster() {
   delay-=10
   if(delay < 0) delay = 0
}
</SCRIPT>

<BODY BGCOLOR="white">

<IMG NAME="animation" SRC="image1.gif" ALT="[Animation]"
   onLoad="setTimeout('animate()', delay)">

<FORM>
   <INPUT TYPE="button" Value="Slower" onClick="slower()">
   <INPUT TYPE="button" Value="Faster" onClick="faster()">
</FORM>
</BODY>

See also the examples for the onAbort, onError, and onLoad event handlers.

See also

Link object; onClick, onMouseOut, onMouseOver event handlers


images

Property. An array reflecting all the images in a document in source order. See the Image object for information.


index ">

index

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

Syntax

1. selectName.options[indexValue].index
2. optionName.index

Parameters

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.

optionName is the name of a Select object option created using the Option() constructor.

Property of

Option object (see the Select object), options array (see the Select object)

Implemented in

Tainted?

No

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])

Parameters

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 zero to stringName.length - 1 or a property of an existing object.

Method of

String

Implemented in

Navigator 2.0

Description

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

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

If stringName contains an empty string (""), indexOf returns an empty string.

The indexOf method is case sensitive. For example, the following expression returns -1:

"Blue Whale".indexOf("blue")

Examples

Example 1. 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"))

Example 2. The following example defines two string variables. The variables contain the same string except that the second string contains uppercase letters. The first writeln method displays 19. But because the indexOf method is case sensitive, the string "cheddar" is not found in myCapString, so the second writeln method displays -1.

myString="brie, pepper jack, cheddar"
myCapString="Brie, Pepper Jack, Cheddar"
document.writeln('myString.indexOf("cheddar") is ' +
   myString.indexOf("cheddar"))
document.writeln('<P>myCapString.indexOf("cheddar") is ' +
   myCapString.indexOf("cheddar"))

See also

charAt, lastIndexOf, split methods


isNaN ">

isNaN

Function. Evaluates an argument to determine if it is "NaN" (not a number).

Syntax

isNaN(testValue)

Parameters

testValue is the value you want to evaluate.

Implemented in

Description

isNaN is a built-in JavaScript function. It is not a method associated with any object, but is part of the language itself.

On platforms that support NaN, the parseFloat and parseInt functions return "NaN" when they evaluate a value that is not a number. isNaN returns true if passed "NaN," and false otherwise.

Examples

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

floatValue=parseFloat(toFloat)

if (isNaN(floatValue)) {
   notFloat()
} else {
   isFloat()
}

See also

NaN property; parseFloat, parseInt functions


italics

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

Syntax

stringName.italics()

Parameters

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

Method of

String

Implemented in

Navigator 2.0

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


javaEnabled

Method. Specifies whether Java is enabled.

Syntax

navigator.javaEnabled()

Method of

navigator

Implemented in

Navigator 3.0

Description

javaEnabled returns true if Java is enabled, false otherwise. The user can enable or disable Java by choosing Network Preferences from the Navigator's Options menu.

Examples

The following code executes function1 if Java is enabled; otherwise it executes function2.

if (navigator.javaEnabled()) {
   function1()
}
else function2()

See also

appCodeName, appName, userAgent properties


join

Method. Joins all elements of an array into a string.

Syntax

arrayName.join(separator)

Parameters

arrayName is the name of an Array object or a property of an existing object.

separator specifies a string to separate each element of the array. The separator is converted to a string if necessary. If omitted, the array elements are separated with a comma (,).

Method of

Array

Implemented in

Navigator 3.0

Description

The string conversion of all array elements are joined into one string.

Examples

The following example creates an array, a with three elements, then joins the array three times: using the default separator, then a comma and a space, and then a plus.

a = new Array("Wind","Rain","Fire")
document.write(a.join() +"<BR>")
document.write(a.join(", ") +"<BR>")
document.write(a.join(" + ") +"<BR>")

This code produces the following output:

Wind,Rain,Fire
Wind, Rain, Fire
Wind + Rain + Fire

See also

reverse, sort methods


lastIndexOf

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

Syntax

stringName.lastIndexOf(searchValue, [fromIndex])

Parameters

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 zero to stringName.length - 1 or a property of an existing object.

Method of

String

Implemented in

Navigator 2.0

Description

Characters in a string are indexed from left to right. The index of the first character is zero, 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.

The lastIndexOf method is case sensitive. For example, the following expression returns -1:

"Blue Whale, Killer Whale".lastIndexOf("blue")

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, split methods


lastModified

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

Syntax

document.lastModified

Property of

document

Implemented in

Navigator 2.0

Tainted?

Yes

Description

The lastModified property is derived from the HTTP header data sent by the web server. Servers generally obtain this date by examining the file's modification date.

The last modified date is not a required portion of the header, and some servers do not supply it. If the server does not return the last modified information, JavaScript receives a zero, which it displays as January 1, 1970 GMT. The following code checks the date returned by lastModified and prints out a value that corresponds to unknown.

lastmod = document.lastModified     // get string of last modified date
lastmoddate = Date.parse(lastmod)   // convert modified string to date
if(lastmoddate == 0){               // unknown date (or January 1,
                                    // 1970 GMT)
   document.writeln("Lastmodified: Unknown")
   } else {
   document.writeln("LastModified: " + lastmod)
}

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
8. arrayName.length

When used with array properties:

9.  anchors.length
10. applets.length
11. arguments.length
12. elements.length
13. embeds.length
14. forms.length
15. frames.length
16. history.length
17. images.length
18. links.length
19. mimeTypes.length
20. plugins.length
21. plugins[mimeTypeIndex].length
22. selectName.options.length

Parameters

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.

arrayName is the name of an Array object.

mimeTypeIndex is either an integer representing a MIME type supported by the plug-in or a string containing the type of a MimeType object (from the type property).

          Property of">

Property of

Implemented in

Tainted?

No

Description

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

For all objects except Array objects, 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 22 of the syntax are the same. For a window containing frames, the values returned by form 7 and form 15 of the syntax are the same. For a Form object, the values returned by form 1 and form 12 of the syntax are the same. For a frame containing frames, the values returned by form 2 and form 15 of the syntax are the same.

For arrays, you can set the length property to truncate an array at any time. You cannot extend an array; for example, if you set length to 3 when it is currently 2, the array will still contain only 2 elements. For information on other ways to change the length of an array, see the Array object.

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)

The following example shortens the array statesUS to a length of 50 if the current length is greater than 50.

if (statesUS.length > 50) {
   statesUS.length=50
   alert("The U.S. has only 50 states. New length is " + statesUS.length)
}


link method

Method. Creates an HTML hypertext link that requests another URL.

Syntax

linkText.link(hrefAttribute)

Parameters

linkText is any string or a property of an existing object. This represents the text that will be displayed in the link.

hrefAttribute is any string that specifies the HREF attribute of the <A> tag; it should be a valid URL (relative or absolute).

Method of

String

Implemented in

Navigator 2.0

Description

Use the link method to programmatically create a hypertext link, and then call write or writeln to display the link in a document.

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://home.netscape.com"

document.write("Click to return to " + hotText.link(URL))

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

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

See also

Anchor object


Link object

Object. A piece of text, an image, or an area of an image identified as a hypertext link. When the user clicks the link text, image, or area, the link hypertext reference is loaded into its target window. Area objects are a type of Link object.

HTML syntax

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

<A HREF=locationOrURL
   [NAME="anchorName"]
   [TARGET="windowName"]
   [onClick="handlerText"]
   [onMouseOut="handlerText"]>
   [onMouseOver="handlerText"]>
   linkText
</A>

You can also define a link using the link method.

To define an area, use standard HTML syntax with the addition of JavaScript event handlers:

<MAP NAME="mapName">
   <AREA
      [NAME="areaName"]
      COORDS="x1,y1,x2,y2,..."|"x-center,y-center,radius"
      HREF="locationOrURL"
      [SHAPE="rect"|"poly"|"circle"|"default"]
      [TARGET="windowName"]
      [onMouseOut="handlerText"]
      [onMouseOver="handlerText"]>
</MAP>

HTML attributes

HREF=locationOrURL identifies a destination anchor or URL. For areas, any region of an image that does not have an HREF attribute does not function as a hyperlink. For areas, this attribute is required if you include the onMouseOut and onMouseOver event handlers. See the location object for a description of the URL components.

NAME="anchorName" is used only if the link is also an anchor. It specifies a name for the anchor that then becomes an available hypertext target within the current document. See the Anchor object for details.

TARGET="windowName" specifies the frame or 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 the text or HTML source that the user sees as a hypertext link to the URL.

NAME="mapName" specifies the name of the map. You can specify this map name in the USEMAP attribute of the <IMG> tag.

AREA defines an area of an image as an image map.

NAME="areaName" specifies the name of the Area object. This attribute is not reflected in JavaScript (you cannot refer to an Area object by name).

COORDS specifies the coordinates of the image map.

SHAPE specifies the shape of the map. "default" specifies a region as the default. If omitted, "rect" is used.

Syntax

To use a Link or Area object's properties:

document.links[index].propertyName

Parameters

index is an integer representing a Link or Area object or the name of a Link or Area object as specified by the NAME attribute.

propertyName is one of the properties listed below.

Property of

document

Implemented in

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.

You can use a Link object to execute a JavaScript function rather than link to a hypertext reference by specifying the javascript: URL protocol for the link's HREF attribute. You might want to do this if the link surrounds an Image object and you want to execute JavaScript code when the image is clicked. Or you might want to use a link instead of a button to execute JavaScript code.

For example, when a user clicks the following links, the slower and faster functions execute:

<A HREF="javascript:slower()">Slower</A>
<A HREF="javascript:faster()">Faster</A>

You can use a Link object to do nothing rather than link to a hypertext reference by specifying the javascript:void(0) URL protocol for the link's HREF attribute. You might want to do this if the link surrounds an Image object and you want to use the link's event handlers with the image. When a user clicks the following link or image, nothing happens:

<A HREF="javascript:void(0)">Click here to do nothing</A>

<A HREF="javascript:void(0)">
   <IMG SRC="images\globe.gif" ALIGN="top" HEIGHT="50" WIDTH="50">
</A>

Area objects

Area objects are in the links array. You cannot refer to an Area object by name; you must use the links array. For example, if a document contains three Area objects, these objects are reflected as document.links[0], document.links[1], and document.links[2]. For information on the links array, see "The links array".

The HREF attribute is required for Area objects that use the onMouseOut or onMouseOver event handlers. However, if you create an Area for an image and do not want the image to link to a hypertext reference when clicked, specify a JavaScript function in the area's HREF attribute by using the javascript: URL protocol. For example, if a user clicks the following Area object, the function onTop executes.

<MAP NAME="worldMap">
   <AREA NAME="topWorld" COORDS="0,0,50,25" HREF="javascript:onTop()"
      onMouseOver="self.status='You are on top of the world';return true"
      onMouseOut="self.status='You have left the top of the world';return true">
</MAP>

If you want an area's link to do nothing, use javascript:void(0) in the HREF attribute. When the user clicks the following Area object, nothing happens:

<MAP NAME="worldMap">
   <AREA NAME="topWorld" COORDS="0,0,50,25" HREF="javascript:void(0)"
      onMouseOver="self.status='You are on top of the world';return true"
      onMouseOut="self.status='You have left the top of the world';return true">
</MAP>

links array ">

The links array

You can reference the Area and Link objects in your code by using the links array. This array contains an entry for each Area (<AREA HREF="..."> tag) and Link (<A HREF=""> tag) object in a document in source order. It also contains links created with the link method.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 or the name of a Link object as specified by the NAME attribute.

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 Area and Link objects have the following properties:

Property Description
hash Specifies an anchor name in the URL
host Specifies the host and domain name, or IP address, of a network host
hostname Specifies the host:port portion of the URL
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 property:

Property Description
length Reflects the number of links in a document

Methods

Event handlers

Area objects have the following event handlers:

Link objects have the following event handlers:

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. The user can use the set of radio buttons to 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://home.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://home.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. In the following example, the linkGetter function uses the links array to display the value of each link in the current document. The example also defines several links and a button for running linkGetter.

function linkGetter() {
   msgWindow=window.open("","msg","width=400,height=400")
   msgWindow.document.write("links.length is " +
      document.links.length + "<BR>")
   for (var i = 0; i < document.links.length; i++) {
      msgWindow.document.write(document.links[i] + "<BR>")
   }
}

<A HREF="http://home.netscape.com">Netscape Home Page</A>
<A HREF="http://www.catalog.com/fwcfc/">China Adoptions</A>
<A HREF="http://www.supernet.net/~dugbrown/">Bad Dog Chronicles</A>
<A HREF="http://www.best.com/~doghouse/homecnt.shtml">Lab Rescue</A>
<P>
<INPUT TYPE="button" VALUE="Display links"
   onClick="linkGetter()">

Example 6: Area object with onMouseOver and onMouseOut event handlers. The following example displays an image, globe.gif. The image uses an image map that defines areas for the top half and the bottom half of the image. The onMouseOver and onMouseOut event handlers display different status bar messages depending on whether the mouse passes over or leaves the top half or bottom half of the image. The HREF attribute is required when using the onMouseOver and onMouseOut event handlers, but in this example the image does not need a hypertext link, so the HREF attribute executes javascript:void(0), which does nothing (see "void" for more information).

<MAP NAME="worldMap">
   <AREA NAME="topWorld" COORDS="0,0,50,25" HREF="javascript:void(0)"
      onMouseOver="self.status='You are on top of the world';return true"
      onMouseOut="self.status='You have left the top of the world';return true">
   <AREA NAME="bottomWorld" COORDS="0,25,50,50" HREF="javascript:void(0)"
      onMouseOver="self.status='You are on the bottom of the world';return true"
      onMouseOut="self.status='You have left the bottom of the world';return true">
</MAP>
<IMG SRC="images\globe.gif" ALIGN="top" HEIGHT="50" WIDTH="50" USEMAP="#worldMap">

Example 7: Refer to Area object with links array. The following code refers to the href property of the first Area object shown in Example 1.

document.links[0].href

Example 8: Simulate an Area object's onClick using the HREF attribute. The following example uses an Area object's HREF attribute to execute a JavaScript function. The image displayed, colors.gif, shows two sample colors. The top half of the image is the color "antiquewhite", and the bottom half is "white". When the user clicks the top or bottom half of the image, the function setBGColor changes the document's background color to the color shown in the image.

<SCRIPT>
function setBGColor(theColor) {
   document.bgColor=theColor
}
</SCRIPT>
Click the color you want for this document's background color
<MAP NAME="colorMap">
   <AREA NAME="topColor" COORDS="0,0,50,25" HREF="javascript:setBGColor('antiquewhite')">
   <AREA NAME="bottomColor" COORDS="0,25,50,50" HREF="javascript:setBGColor('white')">
</MAP>
<IMG SRC="images\colors.gif" ALIGN="top" HEIGHT="50" WIDTH="50" USEMAP="#colorMap">

See also

Anchor object, Image object; link method


linkColor

Property. A string specifying the color of the document hyperlinks.

Syntax

document.linkColor

Property of

document

Implemented in

Navigator 2.0

Tainted?

No

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, vlinkColor properties


links

Property. An array of objects corresponding to Area and Link objects in source order. See the Link object for information.

Tainted?

Yes


LN2

Property. The natural logarithm of two, approximately 0.693.

Syntax

Math.LN2

Property of

Math

Implemented in

Navigator 2.0

Tainted?

No

Description

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

Examples

The following function returns the natural log of two:

function getNatLog2() {
   return Math.LN2
}

See also

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


LN10

Property. The natural logarithm of 10, approximately 2.302.

Syntax

Math.LN10

Property of

Math

Implemented in

Navigator 2.0

Tainted?

No

Description

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

Examples

The following function returns the natural log of 10:

function getNatLog10() {
   return 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.]location.methodName(parameters)

Parameters

windowReference is a variable windowVar from a window definition (see the 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).

methodName is one of the methods listed below.

Property of

window object

Implemented in

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//host:port/pathname#hash?search

For example:

http://home.netscape.com/assist/extensions.html#topic1?x=7&y=2

Following is a description of each part of the URL diagram:

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:

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://home.netscape.com/"
window.location="http://home.netscape.com/"

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.

In event handlers, you must specify window.location instead of simply using location. Due to the scoping of static objects in JavaScript, a call to location without specifying an object name is equivalent to document.location, which is a synonym for document.URL.

Do not use location as a property of the document object; use the document.URL property instead. The document.location property, which is a synonym for document.URL, will be removed in a future release.

How documents are loaded when location is set

When you set the location object or any of its properties except hash, whether a new document is loaded depends on which version of Navigator you are running:

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 type Protocol Example
JavaScript code javascript: javascript:history.go(-1)
Navigator source viewer view-source: view-source:wysiwyg://0/file:/c|/temp/genhtml.html
Navigator info about: about:cache
World Wide Web http: http://home.netscape.com/
File file:/ file:///javascript/methods.html
FTP ftp: ftp://ftp.mine.com/home/mine
MailTo mailto: mailto:@spam@info-Remove- at netscape.com
Usenet news: news://news.scruznet.com/comp.lang.javascript
Gopher gopher: 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 (by calling a void function, for example javascript:void(0)), no new page loads. Note that loading a new page over your script's page clears the page's variables, functions, and so on.

The view-source: protocol displays HTML code that was generated with JavaScript write and writeln methods. For information on printing and saving generated HTML, see the write method.

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

about:[cache|plugins]

Properties

The location object has the following properties:

Property Description
hash Specifies an anchor name in the URL
host Specifies the host and domain name, or IP address, of a network host
hostname specifies the host:port portion of the URL
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

The location object has the following methods:

eval

reload

replace

toString

valueOf

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://home.netscape.com/"
window.location="http://home.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 examples for the Anchor object.

See also

history object; URL property


log

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

Syntax

Math.log(number)

Parameters

number is any positive numeric expression or a property of an existing object.

Method of

Math

Implemented in

Navigator 2.0

Description

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

Examples

The following function returns the natural log of the variable x:

function getLog(x) {
   return Math.log(x)
}

If you pass getLog the value 10, it returns 2.302585092994046; if you pass it the value zero, it returns -1.797693134862316e+308 because zero is out of range.

See also

exp, pow methods


LOG2E

Property. The base 2 logarithm of e (approximately 1.442).

Syntax

Math.LOG2E

Property of

Math

Implemented in

Navigator 2.0

Tainted?

No

Description

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

Examples

The following function returns the base 2 logarithm of E:

function getLog2e() {
   return 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

Implemented in

Navigator 2.0

Tainted?

No

Description

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

Examples

The following function returns the base 10 logarithm of E:

function getLog10e() {
   return Math.LOG10E
}

See also

E, LN2, LN10, LOG2E, PI, SQRT1_2, SQRT2 properties


lowsrc

Property. A string specifying the URL of a low-resolution version of an image to be displayed in a document.

Syntax

imageName.lowsrc

Parameters

imageName is either the name of an Image object or an element in the images array.

Property of

Image

Implemented in

Navigator 3.0

Tainted?

No

Description

The lowsrc property initially reflects the LOWSRC attribute of the <IMG> tag. Navigator loads the smaller image specified by lowsrc and then replaces it with the larger image specified by the src property. You can change the lowsrc property at any time.

Examples

See the examples for the src property.

See also

complete, src properties


[Next reference file]

See also:


file: /Techref/language/java/script/ref_h-l.htm, 135KB, , updated: 2009/2/2 14:27, local time: 2019/3/26 04:18,
TOP NEW HELP FIND: 
54.226.175.101:LOG IN

 ©2019 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE! / 

<A HREF="http://www.piclist.com/techref/language/java/script/ref_h-l.htm"> hash </A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

  PICList 2019 contributors:
o List host: MIT, Site host massmind.org, Top posters @20190326 RussellMc, David Van Horn, AB Pearce - UKRI STFC, Allen Mulvey, James Cameron, Neil, David C Brown, Dwayne Reid, Manu Abraham, Jim,
* Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.
 

Welcome to www.piclist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .