The following entries summarize the various JavaScript objects and independent functions. The properties, constants, arrays, methods, functions, and event handlers for each object are described in the entry for that object. Thus, if you want to read about the write() method of the Document object (Document.write), look it up in the entry for Document.
If you can't remember what object a method or property, etc., goes with, the following table should help. The left column lists the names of all the functions, properties, etc., and the right column gives the name of the object(s) with which they are associated. Since this table serves as something of a table of contents for this section, object names themselves also appear in the left hand column.
We've tried to cram as much useful information as possible into this chapter. But JavaScript has many intricacies to which we cannot do justice in so short a format. For more complete reference information, as well as an excellent guide to using the language, see JavaScript: The Definitive Guide.
| For | See Object | For | See Object | |
|---|---|---|---|---|
| abs( ) | Math | cookie | Document | |
| acos( ) | Math | cos( ) | Math | |
| action | Form | current | History | |
| alert( ) | Window | Date | Date | |
| alinkColor | Document | defaultChecked | Checkbox | |
| Anchor | Anchor | Radio | ||
| anchor( ) | String | defaultSelected | Option | |
| anchors[ ] | Document | defaultStatus | Window | |
| appCodeName | Navigator | defaultValue | Text | |
| applets[ ] | Document | Textarea | ||
| appName | Navigator | description | MimeType | |
| appVersion | Navigator | Plugin | ||
| arguments[ ] | Function | Document | Document | |
| Array | Array | document | Window | |
| asin( ) | Math | domain | Document | |
| assign( ) | Object | E | Math | |
| atan( ) | Math | Element | Element | |
| atan2( ) | Math | elements[ ] | Form | |
| back( ) | History | embeds[ ] | Document | |
| bgColor | Document | enabledPlugin | MimeType | |
| big( ) | String | encoding | Form | |
| blink( ) | String | escape( ) | escape( ) | |
| blur( ) | FileUpload | eval( ) | eval( ) | |
| Password | Object | |||
| Text | exp( ) | Math | ||
| Textarea | fgColor | Document | ||
| Window | FileUpload | FileUpload | ||
| bold( ) | String | filename | Plugin | |
| Boolean | Boolean | fixed( ) | String | |
| border | Image | floor( ) | Math | |
| Button | Button | focus( ) | FileUpload | |
| caller | Function | Password | ||
| ceil( ) | Math | Text | ||
| charAt( ) | String | Textarea | ||
| Checkbox | Checkbox | Window | ||
| checked | Checkbox | fontcolor( ) | String | |
| Radio | fontsize( ) | String | ||
| clear( ) | Document | Form | Form | |
| clearTimeout( ) | Window | form | Button | |
| close( ) | Document | Checkbox | ||
| Window | Element | |||
| closed | Window | FileUpload | ||
| complete | Image | Hidden | ||
| confirm( ) | Window | Password | ||
| form (cont'd) | Radio | length (cont'd) | JavaArray | |
| Reset | Select | |||
| Select | String | |||
| Submit | Window | |||
| Text | Link | Link | ||
| Textarea | link( ) | String | ||
| forms[ ] | Document | linkColor | Document | |
| forward( ) | History | links[ ] | Document | |
| Frame | Frame | LN10 | Math | |
| frames[ ] | Window | LN2 | Math | |
| Function | Function | location | Document | |
| getClass( ) | getClass( ) | Location | Location | |
| getDate( ) | Date | location | Window | |
| getDay( ) | Date | log( ) | Math | |
| getHours( ) | Date | LOG10E | Math | |
| getMinutes( ) | Date | LOG2E | Math | |
| getMonth( ) | Date | lowsrc | Image | |
| getSeconds( ) | Date | Math | Math | |
| getTime( ) | Date | max( ) | Math | |
| getTimezoneOffset( ) | Date | MAX_VALUE | Number | |
| getYear( ) | Date | method | Form | |
| go( ) | History | MimeType | MimeType | |
| hash | Location | mimeTypes | Navigator | |
| height | Image | mimeTypes[ ] | Plugin | |
| Hidden | Hidden | min( ) | Math | |
| History | History | MIN_VALUE | Number | |
| history | Window | name | Button | |
| host | Location | Checkbox | ||
| hostname | Location | Element | ||
| href | Location | FileUpload | ||
| hspace | Image | Hidden | ||
| Image | Image | Image | ||
| images[ ] | Document | MimeType | ||
| index | Option | Password | ||
| indexOf( ) | String | Plugin | ||
| isNaN( ) | isNaN( ) | Radio | ||
| italics( ) | String | Reset | ||
| java | java | Select | ||
| Packages | Submit | |||
| JavaArray | JavaArray | Text | ||
| JavaClass | JavaClass | Textarea | ||
| javaEnabled( ) | Navigator | Window | ||
| JavaObject | JavaObject | NaN | Number | |
| JavaPackage | JavaPackage | Navigator | Navigator | |
| join( ) | Array | navigator | navigator | |
| lastIndexOf( ) | String | NEGATIVE_INFINITY | Number | |
| lastModified | Document | netscape | netscape | |
| length | Array | Packages | ||
| History | next | History | ||
| Number | Number | previous | History | |
| Object | Object | prompt( ) | Window | |
| onabort( ) | Image | protocol | Location | |
| onblur( ) | FileUpload | prototype | Function | |
| Text | Radio | Radio | ||
| Textarea | random( ) | Math | ||
| Window | referrer | Document | ||
| onchange( ) | FileUpload | reload( ) | Location | |
| Select | replace( ) | Location | ||
| Text | Reset | Reset | ||
| Textarea | reset( ) | Form | ||
| onclick( ) | Button | reverse( ) | Array | |
| Checkbox | round( ) | Math | ||
| Link | scroll( ) | Window | ||
| Radio | search | Location | ||
| Reset | Select | Select | ||
| Submit | select( ) | Text | ||
| onerror( ) | Image | selected | Option | |
| Window | selectedIndex | Select | ||
| onfocus( ) | FileUpload | self | Window | |
| Text | setDate( ) | Date | ||
| Textarea | setHours( ) | Date | ||
| Window | setMinutes( ) | Date | ||
| onload( ) | Image | setMonth( ) | Date | |
| Window | setSeconds( ) | Date | ||
| onmouseout( ) | Link | setTime( ) | Date | |
| onmouseover( ) | Link | setTimeout( ) | Window | |
| onreset( ) | Form | setYear( ) | Date | |
| onsubmit( ) | Form | sin( ) | Math | |
| onunload( ) | Window | small( ) | String | |
| open( ) | Document | sort( ) | Array | |
| Window | split( ) | String | ||
| opener | Window | sqrt( ) | Math | |
| Option | Option | SQRT1_2 | Math | |
| options[ ] | Select | SQRT2 | Math | |
| Packages | Packages | src | Image | |
| parent | Window | status | Window | |
| parse( ) | Date | strike( ) | String | |
| parseFloat( ) | parseFloat( ) | String | String | |
| parseInt( ) | parseInt( ) | sub( ) | String | |
| Password | Password | Submit | Submit | |
| pathname | Location | submit( ) | Form | |
| PI | Math | substring( ) | String | |
| Plugin | Plugin | suffixes | MimeType | |
| plugins | Document | sun | Packages | |
| Navigator | sun | |||
| port | Location | sup( ) | String | |
| POSITIVE_INFINITY | Number | taint( ) | taint( ) | |
| pow( ) | Math | taintEnabled( ) | Navigator | |
| tan( ) | Math | UTC( ) | Date | |
| target | Form | value | Button | |
| Link | Checkbox | |||
| text | Option | Element | ||
| Text | Text | FileUpload | ||
| Textarea | Textarea | Hidden | ||
| title | Document | Option | ||
| toGMTString( ) | Date | Password | ||
| toLocaleString( ) | Date | Radio | ||
| toLowerCase( ) | String | Reset | ||
| top | Window | Submit | ||
| toString( ) | Boolean | Text | ||
| Function | Textarea | |||
| Number | valueOf( ) | Object | ||
| Object | vlinkColor | Document | ||
| toUpperCase( ) | String | vspace | Image | |
| type | Element | width | Image | |
| Select | Window | Window | ||
| unescape( ) | unescape( ) | window | Window | |
| untaint( ) | untaint( ) | write( ) | Document | |
| URL | Document | writeln( ) | Document | |
| userAgent | Navigator |
Represents a named position (of an HTML document) that may be the target or destination of a hypertext link. A hypertext link may refer to an anchor by using its name after a # character in a URL. In Netscape 2.0, the elements of the document.anchor[] array are set to null, so it is not possible to actually obtain an Anchor object. See also Document.Link.
document.anchors.length // number of anchors in the document document.anchors[i] // one of the Anchor objects
An Anchor object is created by any standard HTML <a> tag that contains a <name> attribute:
<a name="anchor_name" links may refer to this anchor by this name [ href=URL ] an anchor may also be a link [ target="window_name" ] links may refer to other windows > anchor HTML text </a>
Creates and initializes an array. Along with the usual array capabilities that all JavaScript objects have, the Array object provides additional array functionality: a constructor function for initializing arrays, an automatically updated length field that stores the size of the array, and join(), reverse(), and sort() methods that manipulate the elements of an array. Available in Netscape 3.0. See also Object.
new Array() with no arguments, length field is set to 0 new Array(size) size = number of elements; sets length new Array(element0, element1, ..., elementn) length set to number of elements
Read/write integer specifying the number of elements in the array, or, when the array does not have contiguous elements, a number one larger than the index of the last element in the array. The length property of a new array is initialized when the array is created with the Array() constructor method. Adding new elements to an array created with the Array() constructor updates the length, if necessary:
a = new Array(); a.length initialized to 0
b = new Array(10); b.length initialized to 10
c = new Array("one", "two", "three"); c.length initialized to 3
c[3] = "four"; c.length updated to 4
c[10] = "blastoff"; c.length becomes 11
You can also set the value of the length property to change the size of an array (i.e., truncate elements or add "undefined" ones).
Converts each of the elements of an array to a string, and then concatenates those strings, inserting the specified separator string between the elements. Returns the resulting string. You can split a string up into array elements--with the split() method of the String object.
array.join() array.join(separator) if no separator, the empty string is used
Reverse, in place (i.e., without creating a new array), the order of the elements of an array.
With no arguments, sorts alphabetically (by character encoding); elements are first converted to strings, if necessary, so that they can be compared. To sort the array elements in some other order, you must supply a function that compares two values and returns a number indicating their relative order.
array.sort() array.sort(orderfunc) orderfunc - optional comparison function
The comparison function should take two arguments, a and b, and should:
An object wrapper around the boolean value; exists solely to provide a toString() method to convert boolean values to strings. When the toString() method is invoked to convert a boolean value to a string (and it is often invoked implicitly by JavaScript), JavaScript internally converts the boolean value to a transient Boolean object, on which the method can be invoked.
You can create Boolean objects that are not transient by calling the Boolean() constructor method:
new Boolean(value)
The argument is the value to be held by the Boolean object. This will be converted to a boolean value, if necessary. The values 0, null, and the empty string "" are all converted to false. All other values, including the string "false," are converted to true. Available in Netscape 3.0. See also Object.
Returns true or false, depending on the boolean value represented by the Boolean object.
Returns the boolean value represented by the Boolean object.
Represents a graphical pushbutton in a form within an HTML document. Use a Button object whenever you want to allow the user to trigger some action on your Web page. Note that the Submit and Reset objects are types of Button objects that submit a form and reset a form's values. Often these default actions are sufficient for a form, and you do not need to create any other types of buttons. Available in Netscape 2.0; enhanced in 3.0. See also Element, Form, Reset, Submit.
form.button_name form.elements[i] form.elements['button_name']
Read-only reference to the Form object that contains the specified button object.
Set by the name attribute of the HTML <input> tag that creates the button, this read-only string property provides the name of the button.
form.button_name form.elements['button_name']
See the type property of the Element object (Element.type).
Set by the value attribute of the HTML <input> tag that creates the button, this read-only string property provides text displayed in the Button object.
Invoked when the button is clicked; defined by the onClick attribute of the HTML <input> tag. Value may be any number of JavaScript statements, separated by semicolons, that are executed when the user clicks the button.
<INPUT TYPE="button" a definition of the handler
value="button-text"
onClick="handler-statements">
button.onclick a reference to the handler
button.onclick() an explicit invocation of the handler
A Button object is created with a standard HTML <input> tag, with the addition of the onClick attribute:
<form>
...
<input
type="button" specifies that this is a button
value="label" the text that is to appear within the button;
specifies the value property
[ name="name" ] a name that can later be used to refer to the button;
specifies the name property
[ onClick="handler" ] JavaScript statements to be executed
when the button is clicked
>
...
</form>
Represents a single graphical checkbox in an HTML form. Note that the text that appears next to the checkbox is not part of the Checkbox object itself, and must be specified external to the Checkbox's HTML <input> tag. The onClick event handler allows you to specify JavaScript code to be executed when the Checkbox is checked or "un-checked." The value of the checked property gives the state of the Checkbox; it can also be set to change the state. Available but buggy in Netscape 2.0; enhanced in 3.0. See also Element, Form, Radio.
A Checkbox object with a unique name may be referenced in any of these ways:
form.checkbox_name form.elements[i] form.elements['checkbox_name']
When a form contains a group of checkboxes with the same name, they are placed in an array, and may be referenced as follows:
form.checkbox_name[j] form.checkbox_name.length form.elements[i][j] form.elements[i].length form.elements['checkbox_name'][j] form.elements['checkbox_name'].length
Read/write Boolean property that specifies whether the Checkbox is checked (true) or not (false). Setting the checked property changes the appearance of the Checkbox but does not cause the onclick() event handler to be invoked.
Read-only Boolean property that represents the Checkbox's initial state. May be specified using the checked attribute in the HTML <input> tag. Can be used to reset a Checkbox to its default state.
Read-only reference to the Form object that contains the Checkbox.
Read-only string, set by the HTML name attribute, that specifies the name of the Checkbox object (or array of Checkbox objects).
See the type property of the Element object (Element.type).
Read/write string that specifies the text that is passed to the Web server if the Checkbox is checked when the form is submitted. The initial value of value is specified by the HTML value attribute. If no value attribute is specified, then the default value string is "on."
Invoked when the user clicks on a Checkbox; it is defined by the HTML onClick attribute. The value of this attribute may be any number of JavaScript statements, separated by semicolons, which are executed when the user clicks on the Checkbox.
<INPUT type="checkbox" a definition of the handler
onClick="handler-statements">
checkbox.onclick a reference to the handler
checkbox.onclick(); an explicit invocation of the handler
A Checkbox object is created with a standard HTML <input> tag, with the addition of the new onClick attribute. Multiple Checkbox objects are often created in groups by specifying multiple <input> tags which have the same name attribute.
<form>
...
<input
type="checkbox" specifies that this is a checkbox
[ name="name" ] a name that can later be used to refer to this checkbox
or to the group of checkboxes with this name;
specifies the name property
[ value="value" ] the value returned when this checkbox is selected;
specifies the value property
[ checked ] specifies that the checkbox is initially checked
Specifies the defaultChecked property
[ onClick="handler" ] JavaScript statements to be executed when the
Checkbox is clicked
>
label the HTML text that should appear next to the Checkbox
...
</form>
With no arguments, the Date() method creates a Date object set to the current date and time. Otherwise, the arguments to Date() specify the date, and, optionally, the time, for the new object. The Date object is built into JavaScript and does not have an HTML analog. Most of the Date object methods are invoked through an instance of the Date object. For example:
d = new Date(); //get today's date and time
system.write('Today is: " + d.toLocaleString()); //and print it out
This syntax for creating Date objects assumes that date and time values are specified in local time. When your code must work the same way regardless of the time zone in which it is run, you should specify all your hard-coded dates in the GMT (or UTC) time zone. The most common use of the Data object is to subtract the millisecond representations of the current time from some other time to determine the difference.
Buggy to the point of uselessness in Netscape 2.0. See also Date.parse, Date.UTC(). (Note that the Date.parse() and Date.UTC() functions, though related to Date, do not operate on the Date object.)
To create a Date object, use one of the following five syntaxes. In the third through fifth syntaxes, the specified times are interpreted as local (not GMT) times.
new Date(); new Date(milliseconds) milliseconds between date and 12AM 1/1/70 new Date(date_string); date_string = month_name dd, yy [hh:mm[:ss]] new Date(year, month, day); year minus 1900; month 0-11; day 1-31 new Date(year, month, day, hours, minutes, seconds) 24-hour clock
Returns the day of the month of a Date object. Return values are between 1 and 31.
Returns the day of the week of a Date object. Return values are between 0 (Sunday) and 6 (Saturday).
Returns the hours field of a Date object. Return values are between 0 (midnight) and 23 (11 PM).
Returns the minutes field of a Date object. Return values are between 0 and 59.
Returns the month field of a Date object. Return values are between 0 (January) and 11 (December).
Returns the seconds field of a Date object. Return values are between 0 and 59.
Returns the internal, millisecond representation of a Date object (i.e., the number of milliseconds between midnight GMT on 1/1/1970 and the specified date).
Returns the difference in minutes between this date (in the local time zone) and GMT. Tells you what time zone the JavaScript code is running in. Since getTimezoneOffset is invoked through a Date object, but doesn't reference the Date object, it should actually be its own function.
Returns the year field of a Date object. Return value is the year minus 1900 (e.g., 96 for 1996).
Parses a string representation of a date and returns it in millisecond format.
Sets the day of the month field of a Date object.
date.setDate(day_of_month) // day_of_month is 1-31
Sets the hour field of a Date object.
date.setHours(hours) //hours is integer betw 0 (midnight) and 23 (11pm)
Sets the minutes field of a Date object.
date.setMinutes(minutes) //minutes is integer betw 0 and 59
Sets the month field of a Date object.
date.setMonth(month) //month is integer betw 0 (Jan) and 11 (Dec)
Sets the seconds field of a Date object.
date.setSeconds(seconds) //seconds is integer betw 0 and 59
Sets a Date object in the milliseconds between the desired date/time and midnight GMT on January 1, 1970. Representing a date in this millisecond format makes it independent of time zone.
date.setTime(milliseconds)
Sets the year field of a Date object.
date.setYear(year) // year is year minus 1900; e.g. 96 for 1996
Converts a Date to a string, using the GMT time zone; format of string varies slightly according to platform.
Converts a Date to a string, using the local time zone; uses local conventions for data and time formatting.
Converts a numeric date and time specification to millisecond format.
Date.parse() is a function that is related to the Date object, but it is not a method of (or invoked on) the Date object. Date.parse() parses a date/time string and returns the number of milliseconds between the specified date/time and midnight, January 1st, 1970, GMT. This number can be used directly, used to create a new Date object, or to set the date in an existing Date object with Date.setTime().
Date.parse() understands the IETF standard date format used in email and other Internet communications (e.g., Wed, 8 May 1996 17:41:46 -0400), as well as partial dates of this format; it also understands the GMT time zone, and the standard abbreviations for the time zones of the U.S. Buggy in Netscape 2.0. See also Date, Date.UTC( ).
date.parse(date_string)
Date.UTC() is a function that is related to the Date object, but is not a method of the Date object or invoked on it; it is always invoked as Date.UTC(), not as date.UTC(), on some object date.
Date.UTC converts time in UTC (Universal Coordinated Time) format (i.e., in the GMT zone) to milliseconds. It returns the number of milliseconds between midnight on January 1st, 1970, UTC and the time specified by the arguments. This can be used by the Date() constructor method and by the Date.setTime() method.
For arguments, use: year minus 1900 (e.g., 96 for 1996); month 0 (January) through 11 (December); 24-hour clock for hour (0-23). In Netscape 2.0, Date.UTC() does not compute the correct number of milliseconds. See also Date, Date.parse.
date.UTC(year, month, day, [, hours [, minutes [, seconds ]]]);
To create a Date object using a UTC time specification, you can use code like this:
d = new Date(Date.UTC(96, 4, 8, 16, 30));
The currently displayed HTML document. An instance of the Document object is stored in the document field of the Window object. As a special case, when referring to the Document object of the current window (i.e., the window in which the JavaScript code is executing), you can omit the window reference and simply use document. Available in Netscape 2.0. See also Form, Frame, Window.
window.document document // To refer to Document obj of current window
Note that for all attributes to set a color, the value can be one of the standard color names recognized by JavaScript, or an RGB value in six hexadecimal digits (RRGGBB).
String that specifies the color of activated links (i.e., links being selected by user). Can be set directly in the document <head>, or inherited from the alink attribute in the <body>.
An array of Anchor objects, one for each anchor (i.e., hypertext target) in the document.
Read-only integer specifying the number of elements in the anchors[] array.
An array of Java objects, one for each <applet> that appears in the document.
A read-only integer specifying the number of elements in the applets[] array.
String that specifies the background color of the document. Can be set directly at any point in document, or inherited from the bgcolor attribute in the <body>. Buggy in Netscape 2.0.
A string that is the value of a cookie associated with this document. String property that allows you to read, create, modify, and delete the cookie(s) that apply to the current document. A "cookie" is a small amount of named data stored by the Web browser so that it can use data input on one page in another page, or recall user preferences across Web-browsing sessions.
document.cookie
The read and write values of the cookie property generally differ. In a JavaScript expression, the cookie property returns a string containing all the cookies from the current document, in name=value pairs (separated by semicolons). Use String.indexOf() and String.substring() to determine the value of a particular cookie. Since cookies cannot contain any semicolons, commas, or whitespace, they are commonly encoded using escape() before storing and decoded using unescape() after retrieving.
To associate a cookie value with the current document for the current Web browsing session, set document.cookie to a string of the form name=value. To create a cookie that can last across browser sessions, include an expiration date by setting document.cookie to a string of the form:
name=value; expires=date
date should be a date specification in the format written by Date.toGMTString().
String that specifies the Internet domain which the document is from; used for security purposes.
An array of Java objects, one for each <embed> tag that appears in the document.
Read-only integer that specifies the number of elements in the embeds[] array.
String that specifies the default color of document text. Can be set directly in the document <head>, or inherited from the text attribute in the <body>.
An array of Form objects, one for each <form> that appears in the document.
Read-only integer specifying the number of elements in the forms[] array.
An array of Image objects, one for each image embedded in the document with the <img> tag.
The number of elements in the images[] array.
Read-only string that contains the (local) date and time at which document was most recently modified (derived from the HTTP header).
String that specifies the color of unvisited links. Can be set directly in the document <head>, or inherited from the link attribute in the <body>.
An array of Link objects, one for each hypertext link in the document.
Read-only integer specifying the number of elements in the links[] array.
Synonym for the URL property. Use URL instead because it is less likely to be confused with the Window.location property.
Synonym for the embeds[] array.
The number of elements in the plugins[] or embeds[] array.
Read-only string that contains the URL of the document from which the current document was reached.
Read-only string that specifies the <title> of the document.
Read-only string that specifies the URL of the document that contained the link that referred to the current document.
String that specifies the color of visited links. Can be set directly in the document <head>, or inherited from the vlink attribute in the <body>.
Clears the window or frame that contains document.
Displays any output to document that has been written but not yet displayed, and closes the output stream.
Opens a stream to document, so that subsequent document.write() calls can append data to the document.
Appends each of its arguments, in order, to document. Numeric values are converted to a string representation; boolean values are appended as either "true" or "false." When invoked in scripts that are run while the document is loading, you can call document.write() to insert dynamically generated HTML text into the document.
document.write(value,...)
When invoked within a <script> tag on an HTML document that is being parsed, arguments are appended at the location of the tag; when invoked on a document that is not being parsed, the document must first be opened with Document.open().
Identical to write(), except that it appends a newline character to the output.
The following event handlers are, strictly speaking, properties of Window, not Document:
Invoked when the document is fully loaded. Specified by the onLoad attribute of <body>.
Invoked when the document is unloaded. Specified by the onUnload attribute of <body>.
The Document object obtains values for a number of its properties from attributes of the HTML <body> tag. Further, the HTML contents of a document appear within the <body> and </body> tags.
<body
[ BACKGROUND="imageURL" ] a background image for the document
[ BGCOLOR="color" ] a background color for the document
[ text="color" ] the foreground color of the document's text
[ LINK="color" ] the color for unvisited links
[ alink="color" ] the color for activated links
[ VLINK="color" ] the color for visited links
[ onLoad="handler" ] JavaScript to run when the document is loaded
[ onUnload="handler" ] JavaScript to run when the document is unloaded
>
HTML document contents go here
</body>
Technically speaking, there is no single Element object in JavaScript. Each of the various types of form elements are types of Element objects. Available in Netscape 2.0. See also Button, Checkbox, FileUpload, Form, Hidden, Password, Radio, Reset, Select, Submit, Text, Textarea.
form.elements[i] form.name
Read-only reference to Form object that contains this element.
Read-only string (from the HTML name attribute) that specifies the name of this element. The name of a form element is used for two purposes. First, it is used when the form is submitted. Data for each element in the form is usually submitted in the format:
name=value // name and value are encoded as necessary for transmission
If a name is not specified for a form element, then the data for that element cannot be meaningfully submitted to a Web server. The second use of the name property is to refer to a form element in JavaScript code.
Read-only string property (Netscape 3.0 and later) that specifies the type of the form element. The value depends on the input element:
| Object Type | HTML Tag | type Property |
|---|---|---|
| Button | <input type=button> | "button" |
| Checkbox | <input type=checkbox> | "checkbox" |
| FileUpload | <input type=file> | "file" |
| Hidden | <input type=hidden> | "hidden" |
| Password | <input type=password> | "password" |
| Radio | <input type=radio> | "radio" |
| Reset | <input type=reset> | "reset" |
| Select | <select> | "select-one" |
| Select | <select multiple> | "select-multiple" |
| Submit | <input type=submit> | "submit" |
| Text | <input type=text> | "text" |
| Textarea | <textarea> | "textarea" |
Read/write string property that specifies the value to be sent to the server for this element when the form is submitted; initial value specified by the HTML value attribute. For Button, Submit, and Reset objects, the value property specifies the text to appear within the button.
The built-in escape() function creates and returns a new string that contains an encoded version of s to allow transmission of data. A common use of escape() is to encode cookie values, which have restrictions on the punctuation characters they may contain. Available in Netscape 2.0. See also String, unescape( ).
escape(s) s is the string to be "escaped" or encoded
All spaces, punctuation, and accented characters are converted to the form %xx, where xx is two hexadecimal digits that represent the ISO-8859-1 (Latin-1) encoding of the character. For example:
escape("Hello World!");
yields the string:
Hello%20World%21
A built-in JavaScript function; not a method of any object. Executes the code in its string argument code, which may contain one or more JavaScript statements (separated by semicolons). You can also use eval() to evaluate a JavaScript expression rather than execute a statement. Returns the value of the last expression in code that it evaluates. eval() allows a JavaScript program to dynamically modify the code that it executes.
Crashes Netscape 2.0 on 16-bit Windows (version 3.1) platforms. A possible workaround: use Window.setTimeout( ) with a zero-millisecond delay. In 3.0, eval has become a method of the Object object. See also Object, Window.
eval(code)
Represents a file upload input element in a form. It looks like a text input field, with the addition of a Browse... button that opens a directory browser. Entering a filename into a FileUpload object (either directly or through the browser) causes Netscape to submit the contents of that file along with the form (which must use "multipart/form-data" encoding and the post method). The FileUpload object does not recognize the HTML value attribute to specify an initial value for the input field. For security reasons, only the user may enter a filename; JavaScript may not enter text into the FileUpload field in any way. Available in Netscape 2.0; enhanced in 3.0. See also Element, Form, Text.
form.name form.elements[i] form.elements['name']
Read-only reference to the Form object that contains the FileUpload object.
Read-only string, set by the HTML name attribute, that specifies the name of the FileUpload object. This name can also be used to reference the FileUpload object as a property of its form. (For example, if the name property of a FileUpload object in form foo is "info," then foo.info refers to the FileUpload object.)
Read-only string that specifies the type of this form element. For FileUpload objects, it has the value "file." Available in Netscape 3.0 and later.
Read-only string that specifies the value contained in the input field (which is also the value sent to the server when the form is submitted). In Netscape 2.0, this field is always blank. In 3.0 any filename specified by the user may be read, but the property still may not be set.
Removes the keyboard focus from the FileUpload object. Until focus is granted to some other form element, the user's keystrokes may be ignored by all elements. Due to a bug in Netscape 2.0, the blur() method invokes the onblur() event handler.
Sets the keyboard focus to the FileUpload object. When focus is set, all keystrokes are automatically entered into this object.
Defined by the HTML onBlur attribute, the value of which may be any number of JavaScript statements, separated by semicolons; these statements are executed whenever the FileUpload object loses keyboard focus because of a user action. onblur should only be invoked by direct user actions, but a bug in Netscape 2.0 causes it to be invoked by the FileUpload.blur() method.
Invoked when the user changes the value in the FileUpload object and moves the keyboard focus elsewhere. This event handler is not invoked for every keystroke in the FileUpload object, but only when the user completes an edit.
Invoked when a user action causes the FileUpload object to gain the keyboard focus.
A FileUpload object is created with a standard HTML <input> tag, with the addition of optional attributes for event-handlers:
<form ENCtype="multipart/form-data" method=post> required attributes
...
<input
type="file" specifies that this is a FileUpload object
[ name="name" ] a name that can later be used to refer to this object
specifies the name property
[ size=integer ] how many characters wide the object is
[ maxlength=integer ] max allowed number of input characters
[ onBlur="handler" ] the onblur() event handler
[ onChange="handler" ] the onchange() event handler
[ onFocus="handler" ] the onfocus() event handler
...
Represents an HTML <form> in a document. Each form in a document is represented as an element of the Document.forms[] array. Named forms are also represented by the form_name property of their document, where form_name is the name specified in the name attribute of the <form> tag. Available in Netscape 2.0. See also Button, Checkbox, Element, FileUpload, Hidden, Password, Radio, Reset, Select, Submit, Text, Textarea.
document.form_name document.forms[form_number] document.forms.length
The elements of a form (buttons, input fields, check boxes, and so on) are collected in the Form.elements[] array. Named elements, like named forms, can also be referenced directly by name--the element name is used as a property name of the Form object. Thus, to refer to a Text object element named "phone" within a form named "questionnaire," you might use the JavaScript expression:
document.questionnaire.phone
Read/write string specifying the URL to which the form is to be submitted. Initially specified by the action attribute of the <form> HTML tag.
An array of input elements that appear in the form. Each element is a Button, Checkbox, Hidden, Password, Radio, Reset, Select, Submit, Text or Textarea object.
The number of items in the elements[] array.
Read/write string that specifies the encoding method used for form data. Initially specified by the enctype attribute of the <form> HTML tag. The default encoding of "application/x-www-form-urlencoded" is almost always appropriate.
Read/write string that specifies the technique for submitting the form. It should have the value "get" or "post". Initially specified by the method attribute.
Read/write string that specifies the name of the frame or window in which the results of submitting a form should be displayed. Initially specified by the target attribute. The special names "_top", "_parent", "_self", and "_blank" are also supported for the target property and the target attribute.
Resets each of the input elements of the form to their default values.
Method that submits a form.
Invoked just before the elements of the form are reset. Specified by the onReset attribute.
Invoked just before the form is submitted. Specified by the onSubmit attribute of the <form> tag. This event handler allows form entries to be validated before being submitted.
A Form object is created with a standard HTML <form> tag. JavaScript adds the optional onSubmit event handler attribute to this tag. The form contains any input elements created with the <input> tag between <form> and </form>.
<form
[ name="form_name" ] to name the form in JavaScript
[ target="window_name" ] the name of the window for responses
[ action="url" ] the URL to which the form is submitted
[ method=(get|post) ] the method of form submission
[ enctype="encoding" ] how the form data is encoded
[ onSubmit="handler" ] a handler invoked when form is submitted
>
form text and <input> tags go here
</form>
Though the Frame object is sometimes referred to, there is, strictly speaking, no such object. All frames within a browser window are instances of the Window object, and they contain the same properties and support the same methods, and event handlers as the Window object does. See the Window object, and its properties, methods, and event handlers for details.
Note, however, that there are a few practical differences between Window objects that represent top-level browser windows and those that represent frames within a browser window:
Available in Netscape 2.0.
window.frames[i] window.frames.length frames[i] frames.length
An object wrapper around the basic function data type; this object type exists so that functions can have properties and methods associated with them. When a function value is used in an "object context," i.e., when you attempt to invoke a method or read a property of a function, JavaScript internally converts the function value into a temporary Function object, so that the method can be invoked or the property value read.
function functionname(argname1 [, . . . argname_n)]
{
body // body of function
}
To create a new function, use the Function() constructor method:
new Function([argname1 [, ..., argname_n]], body)
Functions defined in this way are sometimes called "anonymous" because they are not given a name when they are created. Just as JavaScript converts from a function value to a Function object whenever necessary, so it will convert from a Function object (created with the Function() constructor) to a function value whenever you use the object in a function value context--i.e., whenever you invoke it with the () operator. This conversion from Function object to function value is done by the valueOf( ) method.
Since there is no special keyword in JavaScript that refers to the Function object of the currently executing function, you must refer to Function objects by name, as in:
function myfunc()
{
if (myfunc.arguments.length == 0) return;
...
}
Enhanced in Netscape 3.0. See also the Object Object.
An array of arguments that were passed to the function. Can only be accessed from within the body of a function. Note that the arguments[] property is actually just a reference to the Function object itself. Thus, instead of using function.arguments[i] and function.arguments.length, you can use function[i] and function.length.
The number of elements in the arguments[] array.
A reference to the Function object that invoked this one, or null if the function is invoked at the top level. Can only be accessed from within the body of a function. You can print out the caller for debugging purposes, and you can even invoke that function through the caller property.
An object which, for constructor functions, defines properties and methods that will be shared by all objects created with that constructor function. Any objects created through a constructor function will "inherit" the properties and methods defined in that prototype.
Converts the Function object to a string by returning the function definition (a string of valid JavaScript code).
Returns the function value contained in a Function object. See the Object.valueOf( ) method.
A function that takes a JavaObject object and returns the JavaClass object of that JavaObject. Available in Netscape 3.0. See also JavaArray, JavaClass, JavaObject, JavaPackage, and Packages.
getClass(javaobj)
Don't confuse the JavaScript getClass() function with the getClass method of all Java objects. Similarly, don't confuse the JavaScript JavaClass object with the Java java.lang.Class class.
Consider the Java rectangle object created with the following line:
var r = new java.awt.Rectangle();
r is a JavaScript variable that holds a JavaObject object. Calling the JavaScript function getClass() returns a JavaClass object that represents the java.awt.Rectangle class:
var c = getClass(r);
You can see that this is so by comparing this JavaClass object to java.awt.Rectangle:
if (c == java.awt.Rectangle) ...
The Java getClass() method is invoked differently and performs an entirely different function:
c = r.getClass();
After executing the above line of code, c is a JavaObject that represents a java.lang.Class object. This java.lang.Class object is a Java object that is a Java representation of the java.awt.Rectangle class. See your Java documentation for details on what you can do with the java.lang.Class class.
To summarize, you can see that the following expression will always evaluate to true for any JavaObject o:
(getClass(o.getClass()) == java.lang.Class)
An invisible form element that allows arbitrary data to be transmitted to the server when the form is submitted. You can use a Hidden object when you want to transmit additional information, besides the user's input data, to the server. (Cookies can also be used to transmit data from client-to-server; however, cookies are persistent on the client side.)
When an HTML document is generated on the fly by a server, another use of Hidden form elements is to transmit data from the server to the client for later processing by JavaScript on the user's side.
Hidden objects can also be useful for communication between CGI scripts, even without the intervention of JavaScript on the client side. In this usage, one CGI script generates a dynamic HTML page containing hidden data, which is then submitted back to a second CGI script. This hidden data can communicate state information, such as the results of submission of a previous form. Enhanced in Netscape 3.0. See also Element, Form, Document.
form.name form.elements[i] form.elements['name']
Read-only reference to the Form object that contains the Hidden object.
Read-only string, set by the HTML name attribute, that specifies the name of the Hidden object. This is also the name that can be used to reference the Hidden object as a property of its form.
Read-only string that specifies the type of this form element. For Hidden objects, it has the value "hidden." Available in Netscape 3.0 and later.
Read/write string, initially set by the HTML value attribute, which specifies arbitrary data to be transmitted to the server when the form is submitted. This data is never visible to the user.
A Hidden object is created with a standard HTML <input> tag:
<form>
...
<input
type="hidden" specifies that this is a Hidden object
[ name="name" ] a name that can later be used to refer to this object;
specifies the name property
[ value="value" ] the value transmitted when the form is submitted;
specifies the initial value of the value property
>
...
</form>
Read-only array of strings that specify the URLs that have been previously visited by the browser. The contents of this list are equivalent to the URLs listed in Netscape's Go menu. You can use the History object to implement your own Forward and Back buttons, or other navigation controls, within a window.
In Netscape 2.0, and in 3.0 without data tainting, JavaScript can use the length property to determine the number of entries on the History object's URL list, and can use the back(), forward(), and go() methods to cause the browser to revisit any of the URLs on the list, but it cannot directly or indirectly read the URLs stored in the array.
In 3.0 and later, when the data tainting security model is enabled, the elements of the array are available and may be read (but not changed). Additional properties (described below) are also available. See also Location.
window.history frame.history history
Read-only string that specifies the URL of the current document. Only available with data tainting enabled in Netscape 3.0.
The number of URLs that are saved in the History object. (Note that the History object does not provide a property that specifies the position of the current URL in the history list, and because there is no method to move to an absolute position in the history list, only methods to move relative to the current position.)
Read-only string that specifies the URL of the document after this one in the history list. Only available with data tainting enabled in Netscape 3.0.
Read-only string that specifies the URL of the document before this one in the history list. Only available with data tainting enabled in Netscape 3.0.
Go backwards to a previously visited URL (if any). Calling this method has the same effect as a user's click on the Netscape Back button; it's also equivalent to:
history.go(-1);
Go forward to a previously visited URL (if any). Calling this method has the same effect as a user's click on the Netscape Forward button; it's also equivalent to:
history.go(1);
Go to a previously visited URL (if any).
history.go(relative_position); history.go(target_string); //* buggy in 2.0 */
The first form of the History.go() method takes an integer argument (positive argument=forward; negative argument=back) and causes the browser to visit the URL that is the specified number of positions distant in the history list maintained by the History object. Thus history.go(-1) is equivalent to history.back() (and produces the same effect as a user click on the Netscape Back button). Similarly, history.go(3) is equivalent to calling history.forward() three times. In the second syntax, the target_string argument is supposed to make the browser revisit the first (i.e., most recent) URL that contains the specified string. Caveat: This form of the method is buggy in Netscape 2.0 and may cause the browser to crash.
Returns a string of HTML text. When this string is formatted by a browser (i.e., written with document.write()) it displays the browser history as a table of URLs, each with an appropriate hyperlink. Only available with data tainting enabled in Netscape 3.0.
The Image objects in the document.images[] array represent the images embedded in an HTML document using the <img> tag. Only two properties are writeable: src and lowsrc. When you set src, the browser will load the image specified by the new value of the src property, or by the lowsrc property, for low-resolution monitors. (Note that lowsrc must be set before src because the latter starts the download of the new image.) Setting src can be used to change the graphics on a page in response to user actions (e.g., changing the image on a button to indicate that it is or is not available for selection based on whether the user has input certain information).
Available in Netscape 3.0. (Note that because of a bug in Netscape 2.0, all images in a page that contains JavaScript must have width and height attributes specified, even though the Image object is not available in 2.0.) See also Document.
document.images[i] document.images.length document.image-name
You can dynamically create Image objects using the Image() constructor method:
new Image([width, height]);
Read-only integer that specifies the width, in pixels, of the border around an image. Its value is set by the border attribute.
Read-only boolean that specifies whether the image is completely loaded yet; if an error occurs or the loading is aborted, the complete property will be set to true.
Read-only integer that specifies the height, in pixels, of the image. Its value is set by the height attribute.
Read-only integer that specifies the amount of extra horizontal space, in pixels, inserted on the left and right of the image. Its value is set by the hspace attribute.
Read/write string that specifies the URL of an alternate image, suitable for display at low resolutions. Its initial value is set by the lowsrc attribute. Setting this property has no immediate effect; however, if src is set, a new image will be loaded, and on low-resolution systems, the current value of lowsrc will be used instead of the newly updated value of src.
Read-only string, specified by the HTML name attribute, that gives the name of the image. When an image is given a name with the name attribute, a reference to the image is placed in the image-name property in addition to the document.images[] array. Image objects created with the Image() constructor function do not have names, and cannot have names assigned.
Read/write string that specifies the URL of the image to be displayed. Its initial value is set by the src attribute.
Read-only integer that specifies the amount of extra vertical space, in pixels, inserted above and below the image. Its value is set by the vspace attribute.
Read-only integer that specifies the width, in pixels, of the image. Its value is set by the width attribute.
Invoked if the user aborts the download of an image. Defined by the onAbort attribute, the value of which may be any number of JavaScript statements (separated by semicolons) that will be executed when the user aborts loading.
<img src="url
onAbort="handler a definition of the handler
...>
image.onabort a reference to the handler
image.onabort() an explicit invocation of the handler
Invoked if an error occurs while downloading the image. Defined by the onError attribute, the value of which may be any number of JavaScript statements (separated by semicolons) that will be executed when an error occurs during loading.
<img src="url
onError="handler a definition of the handler
...>
image.onerror a reference to the handler
image.onerror() an explicit invocation of the handler
Invoked when the image successfully finishes loading. Defined by the onLoad attribute, the value of which may be any number of JavaScript statements (separated by semicolons) that will be executed when the image is completely loaded.
<img src="url
onLoad="handler a definition of the handler ...>
image.onload a reference to the handler
image.onload() an explicit invocation of the handler
The Image object is created with a standard HTML <img> tag, with the addition of event handlers. Some <img> attributes have been omitted from the syntax below, because they are not used by or accessible from JavaScript.
<img src="url" the image to display
width=pixels the width of the image
height=pixels the height of the image
[ name="image-name" ] a property name for the image
[ lowsrc="url" ] alternate low-resolution image
[ border=pixels ] width of image border
[ hspace=pixels ] extra horizontal space around image
[ vspace=pixels ] extra vertical space around image
[ onLoad=handler ] invoked when image is fully loaded
[ onError=handler ] invoked if error in loading
[ onAbort=handler ] invoked if user aborts load
>
Tests whether an argument (x) is "not a number"; specifically determines whether it is the reserved value NaN, which represents an illegal number (such as the result of dividing zero by zero). This function is required because it is not possible to express the NaN value as a literal in JavaScript. Commonly used to test the results of parseFloat() and parseInt() to see if they represent legal numbers, or to check for arithmetic errors, such as division by zero. Not implemented on all platforms for Netscape 2.0. See also parseFloat, parseInt.
isNaN(x)
A representation of a Java array, which allows JavaScript to read and write the elements of the array using familiar JavaScript array syntax. When reading and writing values from array elements, data conversion between JavaScript and Java representations is handled by the system. Note that Java arrays differ from JavaScript arrays in the following ways. First, Java arrays have a fixed length that is specified when they are created; thus, the JavaArray length field is read-only. Second, Java arrays are typed (i.e., their elements must all be of the same data type); attempting to set an array element to a value of the wrong type will result in a JavaScript error. Available in Netscape 3.0. See also getClass, JavaClass, JavaObject, JavaPackage, Packages.
javaarray.length the length of the array javaarray[index] read or write an array element
Read-only integer that specifies the number of elements in the Java array represented by the JavaArray object.
If java.awt.Polygon is a JavaClass object, you can create a JavaObject representing an instance of the class using:
p = new java.awt.Polygon();
This object p has properties xpoints and ypoints, which are JavaArray objects representing Java arrays of integers. You could initialize the contents of these arrays with JavaScript code like the following:
for(int i = 0; i < p.xpoints.length; i++)
p.xpoints[i] = Math.round(Math.random()*100);
for(int i = 0; i < p.ypoints.length; i++)
p.ypoints[i] = Math.round(Math.random()*100);
JavaScript representation of a Java class. Its properties represent the public static fields and methods (also called class fields and methods) of the represented class; these properties can be used to read and write the static fields and to invoke the static methods of Java classes. Use a for/in loop to enumerate the properties for any given class.
Note that the JavaClass object does not have properties representing the instance fields of a Java class, which are represented by the JavaObject object. However, the JavaClass object does allow for the creation of Java objects (represented by a JavaObject object) using the new keyword and invoking the constructor method of a JavaClass. For primitive data types, conversion between JavaScript values and Java values is handled automatically by the system. Note that Java is a typed language (i.e., each of the fields of an object must adhere to a specific data type). Available in Netscape 3.0. See also getClass, JavaArray, JavaObject, JavaPackage, Packages.
javaclass.static_field read or write a static Java field javaclass.static_method(...) invoke a static method new javaclass(...) create a new Java object
java.lang.System is a JavaClass object that represents the java.lang.System class in Java. The following code reads a static field of this class:
var java_console = java.lang.System.out;
Invoke a static method of this class with a line such as:
var version = java.lang.System.getProperty("java.version");
The JavaClass object allows you to create a new Java object like this:
var java_date = new java.lang.Date();
JavaScript representation of a Java object. Its properties represent the public instance fields and methods defined for the Java object; these properties can be used to read and write the public instance fields and to invoke the public instance methods of a Java object. (The static/class fields and methods are represented by the JavaClass object.) Use the for/in loop to enumerate the properties of any given JavaObject.
For primitive data types, conversion between JavaScript values and Java values is handled automatically by the system. Note that Java is a typed language (i.e., each of the fields of an object must adhere to a specific data type). Available in Netscape 3.0. See also getClass, JavaArray, JavaClass, JavaPackage, Packages.
javaobject.field read or write an instance field javaobject.method(...) invoke an instance method
java.lang is the name of a JavaPackage that contains the JavaClass java.lang.System. This class has the property out, which is a JavaObject. This JavaObject has a property println, which is a method that can be invoked like this:
java.lang.System.out.println("Hello from Java!");
The previous line of code will write a message on the Java console. java.awt.Rectangle is a JavaClass that represents the java.awt.Rectangle class. The following line creates a JavaObject that represents an instance of this class:
var r = new java.awt.Rectangle(0,0,4,5);
Then access the public fields of this JavaObject r using code such as:
var perimeter = 2*r.width + 2*r.height;
A JavaScript representation of a Java package. A package in Java is a collection of related classes. In JavaScript, a JavaPackage can contain classes (represented by the JavaClass object) and it can also contain other JavaPackage objects.
The property naming scheme for the JavaPackage hierarchy mirrors the naming scheme for Java packages. However, the JavaPackage object named java does not actually represent a package in Java, but is simply a convenient placeholder for other JavaPackages that do represent java.lang, javat, java.io, and other important Java classes. Think of the JavaPackage object as representing a Java package representing a directory in the Java class hierarchy.
The java JavaPackage object is actually a property of every Window object, which makes it a "global" variable in client-side JavaScript. Since every JavaScript expression is evaluated in the context of one window or another, you can always just use java and know that you will be referring to the JavaPackage object you want. There are other global JavaPackage objects as well (sun, netscape). The Packages property is a JavaPackage object that contains references to each of these java, sun, and netscape JavaPackages.
Available in Netscape 3.0. See also JavaArray, JavaClass, JavaObject, Packages.
package.package_name refers to another JavaPackage package.class_name refers to a JavaClass object
The properties of a JavaPackage object are the names of the JavaPackage objects and JavaClass objects that it contains. These properties will be different for each individual JavaPackage. Note that it is not possible to use the JavaScript for/in loop to iterate over the list of property names of a Package object; consult a Java reference manual, or examine the Java class hierarchy, to determine the packages and classes contained within any given package.
You can use JavaPackage objects to refer to any Java class. The java.lang.System class, for example, is:
java.lang.System
Or:
Packages.java.lang.System
Similarly, the netscape.javascript.JSObject class is:
Packagestscape.javascript.JSObject
Represents a hypertext link or a clickable area of a client-side image map in an HTML document. A subclass of the Location object; however, Link differs in that it does not load a new URL automatically (i.e., it changes the URL that the link refers to, but the URL is not displayed until the user selects it). Note that in JavaScript, a hypertext link is a Link object, and a named link destination is an Anchor object. Enhanced in Netscape 3.0. See also Anchor, Location.
document.links[] document.links.length
The hash portion of the HREF URL, including the leading hash (#) mark. This portion specifies the name of an anchor within the object referred to by the URL.
The combination of the hostname and port portions of the HREF URL.
The hostname portion of the HREF URL.
The complete URL specified by the HREF property.
The path portion of the HREF URL.
The port portion of the HREF URL.
The protocol portion of the HREF URL, including the trailing colon.
The search or query portion of the HREF URL, including the leading question mark.
The name of a Window object (i.e., a frame or a toplevel browser window) in which the HREF URL should be displayed.
The values of the following attributes may be any number of JavaScript statements separated by semicolons.
Statements invoked when the user clicks on the link. Defined by the onClick attribute of the HTML <a> or <area> tag that defines the hypertext link. The onclick() event handler is invoked before the browser follows the clicked hypertext link.
<a onClick="handler-statements"> a definition of the handler link.onclick a reference to the handler link.onclick(); an explicit invocation of the handler
Statements invoked when the user moves the mouse off of the link. Defined by the onMouseOut attribute of the HTML <a> or <area> tag that defines the hypertext link. Available in 3.0 and later.
<a onMouseOut="handler-statements"> a definition of the handler <area onMouseOut="handler-statements"> another definition link.onmouseout a reference to the handler link.onmouseout(); an explicit invocation of the handler
Statements invoked when the user moves the mouse over the link. The status property of the current window may be set here. Defined by the onMouseOver attribute of the HTML <A> or <area> tag that defines the hypertext link.
<a onMouseOver="handler-statements"> a definition of the handler <area onMouseOver="handler-statements"> another definition link.onmouseover a reference to the handler link.onmouseover(); an explicit invocation of the handler
A Link object is created with standard <a> and </a> tags, with the addition of the onClick, onMouseOver, and onMouseOut event-handler attributes. The HREF attribute is required for all Link objects. If the name attribute is also specified, then an Anchor object is also created:
<A HREF="url"
[ name="anchor_tag" ] creates an Anchor object
[ target="window_name" ] where the HREF should be displayed
[ onClick="handler" ] invoked when link is clicked
[ onMouseOver="handler" ] invoked when mouse is over link
[ onMouseOut="handler" ] invoked when mouse leaves link
>
link text or image the visible part of the link
</A>
In Netscape 3.0 and later, a Link object is also created by each <area> tag within a client-side image map; standard HTML with the addition of event-handler tags:
<MAP name="map_name">
<area SHAPE="area_shape"
COORDS=coordinates
HREF="url"
[ target="window_name" ] where the HREF should be displayed
[ onClick="handler" ] invoked when area is clicked
[ onMouseOut="handler" ] invoked when mouse leaves area
>
. . .
</MAP>
Represents a URL. Each of the properties of the Location object is a read/write string that contains one or more portions of the URL described by the object. The location property of Window object is a Location object that specifies the URL of the document. Changing properties of a Location object of a Window causes the browser to read in the changed URL. To load a new URL, you usually set the location property to a string; or you can set any of the properties of the Location object instead. The href property is commonly used. If you just set the hash property of the window.location object, the browser will jump to the newly specified anchor.
When you set the location or location.href properties to a URL that you have already visited, the browser will either load that URL from the cache, or will check with the server to see if the document has changed and reload it if necessary. In Netscape 2.0, it will always check with the Web server. In 3.0, the action it takes depends on the Verify Document setting in Netscape's Network Preferences.
See also Document, Link, Window.
location window.location document.links[]
The fields of a Location object refer to the various portions of a URL, which has the following general format:
protocol://hostname:port/pathname?search#hash
The hash portion of the URL, including the leading hash mark (#). This portion specifies the name of an anchor within a single HTML file.
location.hash window.location.hash document.links[i].hash
A combination of the hostname and port portions of the URL.
location.host window.location.host document.links[i].host
The hostname portion of the URL.
location.hostname window.location.hostname document.links[i].hostname
The complete URL.
location.href window.location.href document.links[i].href
The path portion of the URL.
location.pathname window.location.pathname document