Math.tan(number)
Implemented in
Navigator 2.0
Description
The tan method returns a numeric value that represents the tangent of the angle.
Examples
The following function returns the tangent of the variable x:
function getTan(x) {
If you pass getTan the value Math.PI/4, it returns 0.9999999999999999.
return Math.tan(x)
} See also
acos, asin, atan, atan2, cos, sin methods
1. formName.target
2. links[index].target
3. areaName.target
document.musicInfo.target="msgWindow"
<INPUT
TYPE="text"
NAME="textName"
VALUE="textValue"
SIZE=integer
[onBlur="handlerText"]
[onChange="handlerText"]
[onFocus="handlerText"]
[onSelect="handlerText"]>
1. textName.propertyName
2. textName.methodName(parameters)
3. formName.elements[index].propertyName
4. formName.elements[index].methodName(parameters)
Property |
Description
defaultValue |
Reflects the VALUE attribute |
name |
Reflects the NAME attribute |
type |
Reflects the TYPE attribute |
value |
Reflects the current value of the Text object's field |
|
---|
<B>Last name:</B> <INPUT TYPE="text" NAME="last_name" VALUE="" SIZE=25>Example 2. The following example creates two Text objects on a form. Each object has a default value. The city object has an onFocus event handler that selects all the text in the field when the user tabs to that field. The state object has an onChange event handler that forces the value to uppercase.
<FORM NAME="form1">See also the examples for the onBlur, onChange, onFocus, and onSelect event handlers.
<BR><B>City: </B><INPUT TYPE="text" NAME="city" VALUE="Anchorage"
SIZE="20" onFocus="this.select()">
<B>State: </B><INPUT TYPE="text" NAME="state" VALUE="AK" SIZE="2"
onChange="this.value=this.value.toUpperCase()">
</FORM>
See also
FileUpload, Form, Password, String, Textarea objects
1. selectName.options[index].text
2. optionName.text
function getChoice() {The previous example assumes that the Select object is similar to the following:
for (var i = 0; i < document.musicForm.musicType.length; i++) {
if (document.musicForm.musicType.options[i].selected == true) {
return document.musicForm.musicType.options[i].text
}
}
return null
}
<SELECT NAME="musicType">
<OPTION SELECTED> R&B
<OPTION> Jazz
<OPTION> Blues
<OPTION> New Age
</SELECT>
<TEXTAREA
NAME="textareaName"
ROWS="integer"
COLS="integer"
[onBlur="handlerText"]
[onChange="handlerText"]
[onFocus="handlerText"]
[onSelect="handlerText"]>
textToDisplay
</TEXTAREA>
1. textareaName.propertyName
2. textareaName.methodName(parameters)
3. formName.elements[index].propertyName
4. formName.elements[index].methodName(parameters)
<B>Description:</B>See also the examples for the onBlur, onChange, onFocus, and onSelect event handlers.
<BR><TEXTAREA NAME="item_description" ROWS=6 COLS=55>
Our storage ottoman provides an attractive way to
store lots of CDs and videos--and it's versatile
enough to store other things as well.
It can hold up to 72 CDs under the lid and 20 videos
in the drawer below.
</TEXTAREA>
See also
Form object, Password object, String object, Text object
document.title
Implemented in
Navigator 2.0
Description
The title property is a reflection of the value specified within the <TITLE> and </TITLE> tags. If a document does not have a title, the title property is null.
title is a read-only property.
Examples
In the following example, the value of the title property is assigned to a variable called docTitle:
var newWindow = window.open("http://www.netscape.com")
var docTitle = newWindow.document.title
dateObjectName.toGMTString()
Implemented in
Navigator 2.0
Description
The exact format of the value returned by toGMTString varies according to the platform.
Examples
In the following example, today is a Date object:
today.toGMTString()
In this example, the toGMTString method converts the date to GMT (UTC) using the operating system's time-zone offset and returns a string value that is similar to the following form. The exact format depends on the platform.
Mon, 18 Dec 1995 17:28:35 GMT
See also
toLocaleString method
dateObjectName.toLocaleString()
Implemented in
Navigator 2.0
Description
If you are trying to pass a date using toLocaleString, be aware that different locales assemble the string in different ways. Using methods such as getHours, getMinutes, and getSeconds gives more portable results.
Examples
In the following example, today is a Date object:
today.toLocaleString()
In this example, toLocaleString returns a string value that is similar to the following form. The exact format depends on the platform.
12/18/95 17:28:35
See also
toGMTString method
stringName.toLowerCase()
Implemented in
Navigator 2.0
Description
The toLowerCase method returns the value of stringName converted to lowercase. toLowerCase does not affect the value of stringName itself.
Examples
The following example displays the lowercase string "alphabet":
var upperText="ALPHABET"
In LiveWire, you can generate the same output by calling the write function instead of using
document.write(upperText.toLowerCase())document.write
.
See also
toUpperCase method
1. top.propertyName
2. top.methodName
3. top.frameName
4. top.frames[index]
Implemented in
Navigator 2.0
Description
The top property refers to the top-most window that contains frames or nested framesets. Use the top property to refer to this ancestor window.
The top property is read-only. The value of the top property is
<object objectReference>
where objectReference is an internal reference.
Examples
The statement top.close()
closes the top-most ancestor window.
The statement top.length
specifies the number of frames contained within the top-most ancestor window. When the top-most ancestor is defined as follows, top.length
returns three:
<FRAMESET COLS="30%,40%,30%">
The following example sets the background color of a frame called myFrame to red. myFrame is a child of the top-most ancestor window.
<FRAME SRC=child1.htm NAME="childFrame1">
<FRAME SRC=child2.htm NAME="childFrame2">
<FRAME SRC=child3.htm NAME="childFrame3">
</FRAMESET>top.myFrame.document.bgColor="red"
Note
This method existed in 2.0 but was undocumented.
objectName.toString([radix])
sealife.toString()
will return [object Image]
.
<IMG NAME="sealife" SRC="imagesseaotter.gif" ALIGN="left" VSPACE="10">When used with an array, toString joins the array and returns one string containing each array element separated by commas. For example, the following code creates an array and writes output using toString to convert the array to a string.
var monthNames = new Array("Jan","Feb","Mar","Apr")The output is as follows:
document.write("monthNames.toString() is " + monthNames.toString())
monthNames.toString() is Jan,Feb,Mar,AprFor Function objects, toString decompiles the function back into a canonical source string.
for (x = 0; x < 10; x++) {The preceding example produces the following output:
document.write("Decimal: ", x.toString(10), " Binary: ", x.toString(2), "<BR>")
}
Decimal: 0 Binary: 0
Decimal: 1 Binary: 1
Decimal: 2 Binary: 10
Decimal: 3 Binary: 11
Decimal: 4 Binary: 100
Decimal: 5 Binary: 101
Decimal: 6 Binary: 110
Decimal: 7 Binary: 111
Decimal: 8 Binary: 1000
Decimal: 9 Binary: 1001
stringName.toUpperCase()
Implemented in
Navigator 2.0
Description
The toUpperCase method returns the value of stringName converted to uppercase. toUpperCase does not affect the value of stringName itself.
Examples
The following example displays the string "ALPHABET":
var lowerText="alphabet"
In LiveWire, you can generate the same output by calling the write function instead of using
document.write(lowerText.toUpperCase())document.write
.
See also
toLowerCase method
video/mpeg
or audio/x-wav
.
1. objectName.type
2. navigator.mimeTypes[index].type
Implemented in
Navigator 3.0
Description
For MimeType objects, the type property is a type supplied by the MIME type itself.
For form elements, the value of the type property is assigned as follows:
type is a read-only property.
Examples
See the examples for the MimeType object.
See also
For MimeType objects: description, enabledPlugin, suffixes properties
unescape("string")
unescape("%26")The following example returns "!#":
unescape("%21%23")
document.URL
Implemented in
Navigator 2.0
Description
URL is a read-only property of document containing the full URL of the document. URL is a string-valued property that usually matches what window.location.href is set to when you load the document, but redirection may change location.href.
Examples
The following example displays the URL of the current document:
document.write("The current URL is " + document.URL)
See also
href
navigator.userAgent
Implemented in
Navigator 2.0
Description
Servers use the value sent in the user-agent header to identify the client.
userAgent is a read-only property.
Examples
The following example displays userAgent information for the Navigator:
document.write("The value of navigator.userAgent is " +
For Navigator 2.0, this displays the following:
navigator.userAgent)The value of navigator.userAgent is Mozilla/2.0 (Win16; I)
See also
appCodeName, appName, appVersion, javaEnabled properties
Date.UTC(year, month, day [, hrs] [, min] [, sec])
Implemented in
Navigator 2.0
Description
UTC takes comma-delimited date parameters and returns the number of milliseconds since January 1, 1970, 00:00:00, Universal Coordinated Time (GMT).
Because UTC is a static method of Date, you always use it as Date.UTC()
, rather than as a method of a Date object you created.
Examples
The following statement creates a Date object using GMT instead of local time:
gmtDate = new Date(Date.UTC(96, 11, 1, 0, 0, 0))
See also
parse method
1. objectName.value
2. radioName[index].value
3. selectName.options.[index].value
4. fileUploadName.value
5. optionName.value
function valueGetter() {This example displays the following values:
var msgWindow=window.open("")
msgWindow.document.write("submitButton.value is " +
document.valueTest.submitButton.value + "<BR>")
msgWindow.document.write("resetButton.value is " +
document.valueTest.resetButton.value + "<BR>")
msgWindow.document.write("helpButton.value is " +
document.valueTest.helpButton.value + "<BR>")
msgWindow.document.close()
}
Query SubmitThe previous example assumes the buttons have been defined as follows:
Reset
Help
<INPUT TYPE="submit" NAME="submitButton">The following function evaluates the value property of a group of radio buttons and displays it in the msgWindow window:
<INPUT TYPE="reset" NAME="resetButton">
<INPUT TYPE="button" NAME="helpButton" VALUE="Help">
function valueGetter() {This example displays the following values:
var msgWindow=window.open("")
for (var i = 0; i < document.valueTest.radioObj.length; i++) {
msgWindow.document.write
("The value of radioObj[" + i + "] is " +
document.valueTest.radioObj[i].value +"<BR>")
}
msgWindow.document.close()
}
onThe previous example assumes the buttons have been defined as follows:
on
on
on
<BR><INPUT TYPE="radio" NAME="radioObj">R&B
<BR><INPUT TYPE="radio" NAME="radioObj" CHECKED>Soul
<BR><INPUT TYPE="radio" NAME="radioObj">Rock and Roll
<BR><INPUT TYPE="radio" NAME="radioObj">Blues
document.vlinkColor
Implemented in
Navigator 2.0
Description
The vlinkColor property is expressed as a hexadecimal RGB triplet or as one of the string literals listed in "Color values". This property is the JavaScript reflection of the VLINK attribute of the <BODY> tag. The default value of this property is set by the user on the Colors tab of the Preferences dialog box, which is displayed by choosing General Preferences from the Options menu. You cannot set this property after the HTML source has been through layout.
If you express the color as a hexadecimal RGB triplet, you must use the format rrggbb. For example, the hexadecimal RGB values for salmon are red=FA, green=80, and blue=72, so the RGB triplet for salmon is "FA8072."
Examples
The following example sets the color of visited links to aqua using a string literal:
document.vlinkColor="aqua"
The following example sets the color of active links to aqua using a hexadecimal triplet:
document.vlinkColor="00FFFF"
See also
alinkColor, bgColor, fgColor, linkColor properties
imageName.vspace
Implemented in
Navigator 3.0
Description
The vspace property reflects the VSPACE attribute of the <IMG> tag. For images created with the Image() constructor, the value of the vspace property is 0.
vspace is a read-only property.
Examples
See the examples for the height property.
See also
border, height, hspace, width properties
imageName.width
Implemented in
Navigator 3.0
Description
The width property reflects the WIDTH attribute of the <IMG> tag. For images created with the Image() constructor, the value of the width property is the actual, not the displayed, width of the image.
width is a read-only property.
Examples
See the examples for the height property.
See also
border, height, hspace, vspace properties
windowVar = window.open("URL", "windowName" [,"windowFeatures"])For details on defining a window, see the open (window object) method.
To use a window object's properties and methods:
1. window.propertyName
To define an event handler for a window object, use the <BODY> or <FRAMESET> tags:
2. window.methodName(parameters)
3. self.propertyName
4. self.methodName(parameters)
5. top.propertyName
6. top.methodName(parameters)
7. parent.propertyName
8. parent.methodName(parameters)
9. windowVar.propertyName
10. windowVar.methodName(parameters)
11. propertyName
12. methodName(parameters)<BODY
...
[onBlur="handlerText"]
[onFocus="handlerText"]
[onLoad="handlerText"]
[onUnload="handlerText"]>
</BODY>
<FRAMESET
ROWS="rowHeightList"
COLS="columnWidthList"
[onBlur="handlerText"]
[onFocus="handlerText"]
[onLoad="handlerText"]
[onUnload="handlerText"]>
[<FRAME SRC="locationOrURL" NAME="frameName">]
</FRAMESET>Note
On some platforms, placing an onBlur or onFocus event handler in a
<FRAMESET> tag has no effect. Please see the release notes (after starting
Netscape, choose Release Notes from the Help menu).
For information on the <BODY> and <FRAMESET> tags, see the document and Frame objects.
To define an onError event handler for a window object:
window.onerror=errorHandler
For information on specifying the onError event handler, see onError event handler.
Parameters
windowVar is the name of a new window. Use this variable when referring to a window's properties, methods, and containership.
windowName is the window name to use in the TARGET attribute of a <FORM> or <A> tag.
propertyName is one of the properties listed below.
methodName is one of the methods listed below.
errorHandler is the keyword null, the name of an error-handling function, or a variable or property that contains null or a valid function reference.
Property of
None
Implemented in
window.close()
or self.close()
. You can use these properties to make your code more readable or to disambiguate the property reference self.status
from a form called status
. See the properties and methods listed below for more examples.
The top and parent properties are also synonyms that can be used in place of the window name. top refers to the top-most Navigator window, and parent refers to a window containing a frameset. See the top and parent properties.
Because the existence of the current window is assumed, you do not have to reference the name of the window when you call its methods and assign its properties. For example, status="Jump to a new location"
is a valid property assignment, and close()
is a valid method call. However, when you open or close a window within an event handler, you must specify window.open()
or window.close()
instead of simply using open()
or close()
. Due to the scoping of static objects in JavaScript, a call to close()
without specifying an object name is equivalent to document.close()
.
When you reference the location object within an event handler, 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
.
You can reference a window's Frame objects in your code by using the frames array. The frames array contains an entry for each frame in a window with a <FRAMESET> tag.
Windows lack event handlers until some HTML is loaded into them containing a <BODY> or <FRAMESET> tag.
Properties
The window object has the following properties:
The following objects are also properties of the window object:
win1.html
, which defines the frames for the first window, contains the following code:
<HTML>
<HEAD>
<TITLE>Window object example: Window 1</TITLE>
</HEAD>
<BODY BGCOLOR="antiquewhite">
<SCRIPT>
window2=open("win2.html","secondWindow",
"scrollbars=yes,width=250, height=400")
document.writeln("<B>The first window has no name: "
+ window.name + "</B>")
document.writeln("<BR><B>The second window is named: "
+ window2.name + "</B>")
</SCRIPT>
<FORM NAME="form1">
<P><INPUT TYPE="button" VALUE="Open a message window"
onClick = "window3=window.open('','messageWindow',
'scrollbars=yes,width=175, height=300')">
<P><INPUT TYPE="button" VALUE="Write to the message window"
onClick="window3.document.writeln('Hey there');
window3.document.close()">
<P><INPUT TYPE="button" VALUE="Close the message window"
onClick="window3.close()">
<P><INPUT TYPE="button" VALUE="Close window2"
onClick="window2.close()">
</FORM>
</BODY>
</HTML>
win2.html
, which defines the content for window2, contains the following code:
<HTML>See also the example for the Frame object.
<HEAD>
<TITLE>Window object example: Window 2</TITLE>
</HEAD>
<BODY BGCOLOR="oldlace"
onLoad="alert('Message from ' + window.name + ': Hello, World.')"
onUnload="alert('Message from ' + window.name + ': I'm closing')">
<B>Some numbers</B>
<UL><LI>one
<LI>two
<LI>three
<LI>four</UL>
</BODY>
</HTML>
See also
document, Frame objects
1. window.propertyName
2. window.methodName
Implemented in
Navigator 2.0
Description
The window property refers to the current window or frame.
Although you can use the window property as a synonym for the current frame, your code is more readable if you use the self property. For example, window.name
and self.name
both specify the name of the current frame, but self.name
is easier to understand.
Use the window property to disambiguate a property of the window object from a form or form element of the same name. You can also use the window property to make your code more readable.
The window property is read-only. The value of the window property is
<object nameAttribute>
where nameAttribute is the NAME attribute if window refers to a frame, or an internal reference if window refers to a window.
Examples
In the following example, window.status
is used to set the status property of the current window. This usage disambiguates the status property of the current window from a form called "status" within the current window.
<A HREF=""
onClick="this.href=pickRandomURL()"
onMouseOver="window.status='Pick a random URL' ; return true">
Go!</A> See also
self property
document.write(expression1 [,expression2], ...[,expressionN])
Implemented in
Navigator 2.0
Description
The write method displays any number of expressions in a document window. You can specify any JavaScript expression with the write method, including numerics, strings, or logicals.
The write method is the same as the writeln method, except the write method does not append a newline character to the end of the output.
Use the write method within any <SCRIPT> tag or within an event handler. Event handlers execute after the original document closes, so the write method will implicitly open a new document of mimeType text/html
if you do not explicitly issue a document.open()
method in the event handler.
Examples
In the following example, the write method takes several arguments, including strings, a numeric, and a variable:
var mystery = "world"
In the following example, the write method takes two arguments. The first argument is an assignment expression, and the second argument is a string literal.
// Displays Hello world testing 123
msgWindow.document.write("Hello ", mystery, " testing ", 123)//Displays Hello world...
In the following example, the write method takes a single argument that is a conditional expression. If the value of the variable age is less than eighteen, the method displays "Minor." If the value of age is greater than or equal to eighteen, the method displays "Adult."
msgWindow.document.write
(mystr = "Hello " + "world...")msgWindow.document.write(status = (age >= 18) ? "Adult" : "Minor")
See also
close (document object), open (document object), writeln methods
document.writeln(expression1 [,expression2], ...[,expressionN])
Implemented in
Navigator 2.0
Description
The writeln method displays any number of expressions in a document window. You can specify any JavaScript expression, including numerics, strings, or logicals.
The writeln method is the same as the write method, except the writeln method appends a newline character to the end of the output. HTML ignores the newline character, except within certain tags such as <PRE>.
Use the writeln method within any <SCRIPT> tag or within an event handler. Event handlers execute after the original document closes, so the writeln method will implicitly open a new document of mimeType text/html
if you do not explicitly issue a document.open()
method in the event handler.
Examples
All the examples used for the write method are also valid with the writeln method.
See also
close (document object), open (document object), write methods