A string specifying the color of the document text.
document.fgColor
The fgColor property is expressed as a hexadecimal RGB triplet or as one of the string literals listed in Color Values. This property is the JavaScript reflection of the TEXT attribute of the <BODY> tag. The default value of this property is set by the user on the Colors tab of the Preferences dialog box, which is displayed by choosing General Preferences from the Options menu. You cannot set this property after the HTML source has been through layout.
If you express the color as a hexadecimal RGB triplet, you must use the format rrggbb. For example, the hexadecimal RGB values for salmon are red=FA, green=80, and blue=72, so the RGB triplet for salmon is "FA8072".
You can override the value set in the fgColor property in either of the following ways:
The following example sets the color of the foreground text to aqua using a string literal:
document.fgColor="aqua"
The following example sets the color of the foreground text to aqua using a hexadecimal triplet:
document.fgColor="00FFFF"
Causes a string to be displayed in fixed-pitch font as if it were in a <TT> tag.
stringName.fixed()
stringName is any string or a property of an existing object.
Use the fixed method with the write or writeln methods to format and display a string in a document.
var worldString="Hello, world" document.write(worldString.fixed())
The previous example produces the same output as the following HTML:
<TT>Hello, world</TT>
Returns the greatest integer less than or equal to a number.
Math.floor(number)
number is any numeric expression or a property of an existing object.
//Displays the value 45 document.write("<P>The floor of 45.95 is " + Math.floor(45.95)) //Displays the value -46 document.write("<P>The floor of -45.95 is " + Math.floor(-45.95))
Gives focus to the specified object.
1. passwordName.focus() 2. selectName.focus() 3. textName.focus() 4. textareaName.focus()
passwordName is either the value of the NAME attribute of a password 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.
textName is either the value of the NAME attribute of a text object or an element in the elements array.
textareaName is either the value of the NAME attribute of a textarea object or an element in the elements array.
password, select, text, textarea
Use the focus method to navigate to a specific form element and give it focus. You can then either programatically enter a value in the element or let the user enter a value.
In the following example, the checkPassword function confirms that a user has entered a valid password. If the password is not valid, the focus method returns focus to the password object and the select method highlights it so the user can re-enter the password.
function checkPassword(userPass) { if (badPassword) { alert("Please enter your password again.") userPass.focus() userPass.select() } }This example assumes that the password is defined as:
<INPUT TYPE="password" NAME="userPass">
Causes a string to be displayed in the specified color as if it were in a <FONT COLOR=color> tag.
stringName.fontcolor(color)
stringName is any string or a property of an existing object.
color is a string or a property of an existing object, expressing the color as a hexadecimal RGB triplet or as one of the string literals listed in Color Values.
Use the fontcolor method with the write or writeln methods to format and display a string in a document.
If you express 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".
The fontcolor method overrides a value set in the fgColor property.
var worldString="Hello, world" document.write(worldString.fontcolor("maroon") + " is maroon in this line") document.write("<P>" + worldString.fontcolor("salmon") + " is salmon in this line") document.write("<P>" + worldString.fontcolor("red") + " is red in this line") document.write("<P>" + worldString.fontcolor("8000") + " is maroon in hexadecimal in this line") document.write("<P>" + worldString.fontcolor("FA8072") + " is salmon in hexadecimal in this line") document.write("<P>" + worldString.fontcolor("FF00") + " is red in hexadecimal in this line")
The previous example produces the same output as the following HTML:
<FONT COLOR="maroon">Hello, world</FONT> is maroon in this line <P><FONT COLOR="salmon">Hello, world</FONT> is salmon in this line <P><FONT COLOR="red">Hello, world</FONT> is red in this line <FONT COLOR="8000">Hello, world</FONT> is maroon in hexadecimal in this line <P><FONT COLOR="FA8072">Hello, world</FONT> is salmon in hexadecimal in this line <P><FONT COLOR="FF00">Hello, world</FONT> is red in hexadecimal in this line
Causes a string to be displayed in the specified font size as if it were in a <FONTSIZE=size> tag.
stringName.fontsize(size)
stringName is any string or a property of an existing object.
size is an integer between one and seven, or a string representing a signed integer between 1 and 7, or a property of an existing object.
Use the fontsize method with the write or writeln methods to format and display a string in a document. When you specify size as an integer, you set the size of stringName to one of the seven defined sizes. When you specify size as a string such as "-2", you adjust the font size of stringName relative to the size set in the <BASEFONT> tag.
var worldString="Hello, world" document.write(worldString.small()) document.write("<P>" + worldString.big()) document.write("<P>" + worldString.fontsize(7))
The previous example produces the same output as the following HTML:
<SMALL>Hello, world</SMALL> <P><BIG>Hello, world</BIG> <P><FONTSIZE=7>Hello, world</FONTSIZE>
Lets users input text and make choices from form objects such as checkboxes, radio buttons, and selection lists. You can also use a form to post data to a server.
To define a form, use standard HTML syntax with the addition of the onSubmit event handler:
<FORM NAME="formName" TARGET="windowName" ACTION="serverURL" METHOD=GET | POST ENCTYPE="encodingType" [onSubmit="handlerText"]> </FORM>
NAME="formName" specifies the name of the form object.
TARGET="windowName" specifies the window that form responses go to. When you submit a form with a TARGET attribute, server responses are displayed in the specified window instead of the window that contains the form. 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). Some values for this attribute may require specific values for other attributes. See RFC 1867 for details. You can access this value using the target property.
ACTION="serverURL" specifies the URL of the server to which form field input information is sent. This attribute can specify a CGI or LiveWire application on the server; it can also be a mailto: URL if the form is to be mailed. See the location object for a description of the URL components. Some values for this attribute may require specific values for other attributes. See RFC 1867 for details. You can access this value using the action property.
METHOD=GET | POST specifies how information is sent to the server specified by ACTION. GET (the default) appends the input information to the URL which on most receiving systems becomes the value of the environment variable QUERY_STRING. POST sends the input information in a data body which is available on stdin with the data length set in the environment variable CONTENT_LENGTH. Some values for this attribute may require specific values for other attributes. See RFC 1867 for details. You can access this value using the method property.
ENCTYPE="encodingType" specifies the MIME encoding of the data sent: "application/x-www-form-urlencoded" (the default) or "multipart/form-data". Some values for this attribute may require specific values for other attributes. See RFC 1867 for details. You can access this value using the encoding property.
To use a form object's properties and methods:
1. formName.propertyName 2. formName.methodName(parameters) 3. forms[index].propertyName 4. forms[index].methodName(parameters)formName is the value of the NAME attribute of a form object.
Each form in a document is a distinct object.
You can reference a form's elements in your code by using the element's name (from the NAME attribute) or the elements array. The elements array contains an entry for each element (such as a checkbox, radio, or text object) in a form.
You can reference the forms in your code by using the forms array (you can also use the form name). This array contains an entry for each form object (<FORM> tag) in a document in source order. For example, if a document contains three forms, these forms are reflected as document.forms[0], document.forms[1], and document.forms[2].
To use the forms array:
1. document.forms[index] 2. document.forms.length
index is an integer representing a form in a document.
To obtain the number of forms in a document, use the length property: document.forms.length.
You can also refer to a form's elements by using the forms array. For example, you would refer to a text object named quantity in the second form as document.forms[1].quantity. You would refer to the value property of this text object as document.forms[1].quantity.value.
Elements in the forms array are read-only. For example, the statement document.forms[0]="music" has no effect.
The value of each element in the forms array is <object nameAttribute>, where nameAttribute is the NAME attribute of the form.
The form object has the following properties:
The following objects are also properties of the form object:
The forms array has the following properties:
Example 1: named form. The following example creates a form called form1 that contains text fields for first name and last name. The form also contains two buttons that change the names to all upper case or all lower case. The function setCase shows how to refer to the form by its name.
If the form name is musicType, the alert displays the following message:
Example 3: onSubmit event handler. The following example shows an onSubmit event handler that determines whether to submit a form. The form contains one text object where the user enters three characters. The onSubmit event handler calls a function, checkData, that returns true if the number of characters is three; otherwise, it returns false. Notice that the form's onSubmit event handler, not the submit button's onClick event handler, calls the checkData function. Also, the onSubmit event handler contains a return statement that returns the value obtained with the function call.
Example 4: submit method. The following example is similar to the previous one, except it submits the form using the submit method instead of a submit object. The form's onSubmit event handler does not prevent the form from being submitted. The form uses a button's onClick event handler to call the checkData function. If the value is valid, the checkData function submits the form by calling the form's submit method.
An array of objects corresponding to the forms (<FORM> tags) in a document in source order. See form object.
Loads the next URL in the history list.
history.forward()
This method performs the same action as a user choosing the Forward button in the Navigator. The forward method is the same as history.go(1).
<P><INPUT TYPE="button" VALUE="< Back" onClick="history.back()"> <P><INPUT TYPE="button" VALUE="> Forward" onClick="history.forward()">
A window that can display multiple, independently scrollable frames on a single screen, each with its own distinct URL. Frames can point to different URLs and be targeted by other URLs, all within the same screen. A series of frames makes up a page.
To define a frame object, use standard HTML syntax. The onLoad and onUnload event handlers are specified in the <FRAMESET> tag but are actually event handlers for the window object:
<FRAMESET ROWS="rowHeightList" COLS="columnWidthList" [onLoad="handlerText"] [onUnload="handlerText"]> [<FRAME SRC="locationOrURL" NAME="frameName">] </FRAMESET>ROWS="rowHeightList" is a comma-separated list of values specifying the row-height of the frame. An optional suffix defines the units. Default units are pixels.
To use a frame object's properties:
1. [windowReference.]frameName.propertyName 2. [windowReference.]frames[index].propertyName 3. window.propertyName 4. self.propertyName 5. parent.propertyNamewindowReference is a variable windowVar from a window definition (see window object), or one of the synonyms top or parent.
The <FRAMESET> tag is used in an HTML document whose sole purpose is to define the layout of frames that ma