For each property, the "Tainted?" section indicates whether the property is tainted by default. For information on tainting, see "Using data tainting for security", "taint", and "untaint".
Method. Returns the absolute value of a number.
Math.abs(number)
number is any numeric expression or a property of an existing object.
The following function returns the absolute value of the variable x:
function getAbs(x) {
return Math.abs(x)
}
Method. Returns the arc cosine (in radians) of a number.
Math.acos(number)
number is a numeric expression between -1 and 1, or a property of an existing object.
The following function returns the arc cosine of the variable x:
function getAcos(x) {
return Math.acos(x)
}
asin, atan, atan2, cos, sin, tan methods
Property. A string specifying a destination URL for form data that is submitted.
formName.action
formName is either the name of a form or an element in the forms array.
The action property is a reflection of the ACTION attribute of the <FORM> tag. Each section of a URL contains different information. See the location object for a description of the URL components.
You can set the action property at any time.
document.musicForm.action=urlName
encoding, method, target properties; Form object
Method. Displays an Alert dialog box with a message and an OK button.
alert("message")
message is any string or a property of an existing object.
An alert dialog box looks as follows:
Use the alert method to display a message that does not require a user decision. The message argument specifies a message that the dialog box contains.
You cannot specify a title for an alert dialog box, but you can use the open method to create your own "alert" dialog. See open (window object).
function testValue(textElement) {
if (textElement.length > 8) {
alert("Please enter a name that is 8 characters or less")
}
}
Name: <INPUT TYPE="text" NAME="userName"
onBlur="testValue(userName.value)">
document.alinkColor
The alinkColor 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 ALINK attribute of the <BODY> tag. You cannot set this property after the HTML source has been through layout.
The following example sets the color of active links using a string literal:
document.alinkColor="aqua"
The following example sets the color of active links to aqua using a hexadecimal triplet:
document.alinkColor="00FFFF"
bgColor, fgColor, linkColor, vlinkColor properties
Method. Creates an HTML anchor that is used as a hypertext target.
text.anchor(nameAttribute)
text is any string or a property of an existing object.
nameAttribute is any string or a property of an existing object.
Anchors created with the anchor method become elements in the anchors array. See the Anchor object for information about the anchors array.
The following example opens the msgWindow window and creates an anchor for the Table of Contents:
var myString="Table of Contents"
msgWindow.document.writeln(myString.anchor("contents_anchor"))
The previous example produces the same output as the following HTML:
<A NAME="contents_anchor">Table of Contents</A>
Object. A place in a document that is the target of a hypertext link.
To define an anchor, use standard HTML syntax:
<A [HREF=locationOrURL]
NAME="anchorName"
[TARGET="windowName"]>
anchorText
</A>
You can also define an anchor using the anchor method.
anchorText specifies the text or HTML source to display at the anchor.
1. document.anchors[index]
2. document.anchors.length
The anchors object has no properties.
The anchors array has the following properties:
Property | Description |
---|---|
length |
Reflects the number of named anchors in the document
|
Example 1: An anchor. The following example defines an anchor for the text "Welcome to JavaScript":
<A NAME="javascript_intro"><H2>Welcome to JavaScript</H2></A>
<A HREF="intro.html#javascript_intro">Introduction</A>
link1.html
, which defines the first window
and its buttons, contains the following code:
<HTML>
<HEAD>
<TITLE>Links and Anchors: Window 1</TITLE>
</HEAD>
<BODY>
<SCRIPT>
window2=open("link2.html","secondLinkWindow",
"scrollbars=yes,width=250, height=400")
function linkToWindow(num) {
if (window2.document.anchors.length > num)
window2.location.hash=num
else
alert("Anchor does not exist!")
}
</SCRIPT>
<B>Links and Anchors</B>
<FORM>
<P>Click a button to display that anchor in window #2
<P><INPUT TYPE="button" VALUE="0" NAME="link0_button"
onClick="linkToWindow(this.value)">
<INPUT TYPE="button" VALUE="1" NAME="link0_button"
onClick="linkToWindow(this.value)">
<INPUT TYPE="button" VALUE="2" NAME="link0_button"
onClick="linkToWindow(this.value)">
<INPUT TYPE="button" VALUE="3" NAME="link0_button"
onClick="linkToWindow(this.value)">
<INPUT TYPE="button" VALUE="4" NAME="link0_button"
onClick="linkToWindow(this.value)">
</FORM>
</BODY>
</HTML>
link2.html
, which contains the anchors, contains
the following code:
<HTML>
<HEAD>
<TITLE>Links and Anchors: Window 2</TITLE>
</HEAD>
<BODY>
<A NAME="0"><B>Some numbers</B> (Anchor 0)</A>
<UL><LI>one
<LI>two
<LI>three
<LI>four</UL>
<P><A NAME="1"><B>Some colors</B> (Anchor 1)</A>
<UL><LI>red
<LI>orange
<LI>yellow
<LI>green</UL>
<P><A NAME="2"><B>Some music types</B> (Anchor 2)</A>
<UL><LI>R&B
<LI>Jazz
<LI>Soul
<LI>Reggae
<LI>Rock</UL>
<P><A NAME="3"><B>Some countries</B> (Anchor 3)</A>
<UL><LI>Afghanistan
<LI>Brazil
<LI>Canada
<LI>Finland
<LI>India</UL>
</BODY>
</HTML>
Property. An array of objects corresponding to named anchors in source order. See the Anchor object for information.
Property. A string specifying the code name of the browser.
navigator.appCodeName
appCodeName is a read-only property.
The following example displays the value of the appCodeName property:
document.write("The value of navigator.appCodeName is " +
navigator.appCodeName)
For Navigator 2.0 and 3.0, this displays the following:
The value of navigator.appCodeName is Mozilla
appName, appVersion, javaEnabled, userAgent properties
Object. Includes a Java applet in a web page.
To include a Java applet in a web page, use standard HTML syntax:
<APPLET
CODE=classFileName
HEIGHT=height
WIDTH=width
MAYSCRIPT
[NAME=appletName]
[CODEBASE=classFileDirectory]
[ALT=alternateText]
[ALIGN="left"|"right"|
"top"|"absmiddle"|"absbottom"|
"texttop"|"middle"|"baseline"|"bottom"]
[HSPACE=spaceInPixels]
[VSPACE=spaceInPixels]>
[<PARAM NAME=parameterName VALUE=parameterValue>]
[ ... <PARAM>]
</APPLET>
HEIGHT=height specifies the height of the applet in pixels within the browser window.
WIDTH=width specifies the width of the applet in pixels within the browser window.
ALT=alternateText specifies text to display for browsers that do not support the <APPLET> tag.
ALIGN=alignment specifies the alignment of the applet on the HTML page.
<PARAM> defines a parameter for the applet.
NAME=parameterName specifies the name of the parameter.
VALUE=parameterValue> specifies a value for the parameter.
document.applets[index]
<APPLET CODE="musicPicker.class" WIDTH=200 HEIGHT=35
NAME="musicApp" MAYSCRIPT>
Accessing JavaScript when the MAYSCRIPT attribute is not specified results in an exception.
For more information on using applets, see Chapter 4, "LiveConnect."
1. document.applets[index]
2. document.applets.length
To obtain the number of applets in a document, use the
length property: document.applets.length
.
All public properties of the applet are available for JavaScript access to the Applet object.
The applets array has the following properties:
Property | Description |
---|---|
length |
Reflects the number of <APPLET> tags in the document
|
The following code launches an applet called "musicApp":
<APPLET CODE="musicSelect.class" WIDTH=200 HEIGHT=35
NAME="musicApp" MAYSCRIPT>
</APPLET>
For more examples, see Chapter 4, "LiveConnect."
MimeType, Plugin objects; Chapter 4, "LiveConnect"
Property. An array reflecting all the applets in a document in source order. See the Applet object for information.
Property. A string specifying the name of the browser.
navigator.appName
appName is a read-only property.
The following example displays the value of the appName property:
document.write("The value of navigator.appName is " +
navigator.appName)
For Navigator 2.0 and 3.0, this displays the following:
The value of navigator.appName is Netscape
appCodeName, appVersion, javaEnabled, userAgent properties
Property. A string specifying version information for the Navigator.
navigator.appVersion
The appVersion property specifies version information in the following format:
releaseNumber (platform; country)
The values contained in this format are the following:
appVersion is a read-only property.
Example 1. The following example displays version information for the Navigator:
document.write("The value of navigator.appVersion is " +
navigator.appVersion)
For Navigator 2.0 on Windows 95, this displays the following:
The value of navigator.appVersion is 2.0 (Win95, I)
For Navigator 3.0 on Windows NT, this displays the following:
The value of navigator.appVersion is 3.0 (WinNT, I)
<SCRIPT>
var newline=null
function populate(textareaObject){
if (navigator.appVersion.lastIndexOf('Win') != -1)
newline="\r\n"
else newline="\n"
textareaObject.value="line 1" + newline + "line 2" + newline
+ "line 3"
}
</SCRIPT>
<FORM NAME="form1">
<BR><TEXTAREA NAME="testLines" ROWS=8 COLS=55></TEXTAREA>
<P><INPUT TYPE="button" VALUE="Populate the Textarea object"
onClick="populate(document.form1.testLines)">
</TEXTAREA>
</FORM>
appCodeName, appName, userAgent properties
Object. Defines an area of an image as an image map. When the user clicks the area, the area's hypertext reference is loaded into its target window. Area objects are a type of Link object. For information on Area objects, see Link object.
Property. An array corresponding to elements of a function.
1. functionName.arguments[index]
2. functionName.arguments.length
Function object, any user-defined function (see See "Defining and calling functions")
The arguments array has the following properties:
Property | Description |
---|---|
length |
Reflects the number of arguments to the function
|
function list(type) {
document.write("<" + type + "L>")
for (var i=1; i<list.arguments.length; i++) {
document.write("<LI>" + list.arguments[i])
document.write("</" + type + "L>")
}
}
list("U", "One", "Two", "Three")
<UL>
<LI>One
<LI>Two
<LI>Three
</UL>
Property. An array of elements in a function. See the arguments array for information.
Object. Lets you create arrays and work with them.
1. arrayObjectName = new Array([arrayLength])
2. arrayObjectName = new Array([element0, element1, ..., elementn])
1. arrayObjectName.propertyName
2. arrayObjectName.methodName(parameters)
arrayLength is the initial length of the array. You can access this value using the length property.
propertyName is one of the properties listed below.
methodName is one of the methods listed below.
The Array object is a built-in JavaScript object.
billingMethod = new Array(5)
musicTypes = new Array(25)
musicTypes[0] = "R&B"
musicTypes[1] = "Blues"
musicTypes[2] = "Jazz"
colors = new Array()
colors[99] = "midnightblue"
myArray = new Array("Hello", myVar, 3.14159)
myArray = new Array("Wind","Rain","Fire")
You can then refer to the first element of the array as
myArray[0]
or myArray["Wind"]
.
The Array object has the following properties:
Property | Description |
---|---|
length |
Reflects the number of elements in an array |
prototype |
Lets you add a properties to an Array object.
|
The Array object has the following methods:
msgArray = new Array()
msgArray [0] = "Hello"
msgArray [99] = "world"
if (msgArray .length == 100) // This is true, because defined msgArray [99] element.
document.write("The length is 100.")
See also the examples for the onError event handler.
a = new Array(4)
for (i=0; i < 4; i++) {
a[i] = new Array(4)
for (j=0; j < 4; j++) {
a[i][j] = "["+i+","+j+"]"
}
}
for (i=0; i < 4; i++) {
str = "Row "+i+":"
for (j=0; j < 4; j++) {
str += a[i][j]
}
document.write(str,"<p>")
}
This example displays the following results:
Multidimensional array test
Row 0:[0,0][0,1][0,2][0,3]
Row 1:[1,0][1,1][1,2][1,3]
Row 2:[2,0][2,1][2,2][2,3]
Row 3:[3,0][3,1][3,2][3,3]
Image object
Method. Returns the arc sine (in radians) of a number.
Math.asin(number)
number is a numeric expression between -1 and 1, or a property of an existing object.
The following function returns the arc sine of the variable x:
function getAsin(x) {
return Math.asin(x)
}
acos, atan, atan2, cos, sin, tan methods
Method. Returns the arc tangent (in radians) of a number.
Math.atan(number)
The atan method returns a numeric value between -pi/2 and pi/2 radians.
The following function returns the arc tangent of the variable x:
function getAtan(x) {
return Math.atan(x)
}
acos, asin, atan2, cos, sin, tan methods
Method. Returns the angle in radians from the X axis to a point.
Math.atan2(x,y)
atan2 is passed separate x and y arguments, and atan is passed the ratio of those two arguments.
The following function returns the angle of the polar coordinate:
function getAtan2(x,y) {
return Math.atan2(x,y)
}
acos, asin, atan, cos, sin, tan methods
Method. Loads the previous URL in the history list.
history.back()
The following custom buttons perform the same operations as the Navigator Back and Forward buttons:
<P><INPUT TYPE="button" VALUE="< Back"
onClick="history.back()">
<P><INPUT TYPE="button" VALUE="> Forward"
onClick="history.forward()">
Property. A string specifying the color of the document background.
document.bgColor
The bgColor 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 BGCOLOR 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 can set the bgColor property at any time.
The following example sets the color of the document background to aqua using a string literal:
document.bgColor="aqua"
The following example sets the color of the document background to aqua using a hexadecimal triplet:
document.bgColor="00FFFF"
alinkColor, fgColor, linkColor, vlinkColor properties
Method. Causes a string to be displayed in a big font as if it were in a <BIG> tag.
stringName.big()
stringName is any string or a property of an existing object.
Use the big method with the write or writeln methods to format and display a string in a document.
The following example uses string methods to change the size of a string:
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>
Method. Causes a string to blink as if it were in a <BLINK> tag.
stringName.blink()
stringName is any string or a property of an existing object.
Use the blink method with the write or writeln methods to format and display a string in a document.
The following example uses string methods to change the formatting of a string:
var worldString="Hello, world"
document.write(worldString.blink())
document.write("<P>" + worldString.bold())
document.write("<P>" + worldString.italics())
document.write("<P>" + worldString.strike())
The previous example produces the same output as the following HTML:
<BLINK>Hello, world</BLINK>
<P><B>Hello, world</B>
<P><I>Hello, world</I>
<P><STRIKE>Hello, world</STRIKE>
Method. Removes focus from the specified object.
1. fileUploadName.blur()
2. passwordName.blur()
3. selectName.blur()
4. textName.blur()
5. textareaName.blur()
6. frameReference.blur()
7. windowReference.blur()
frameReference is a valid way of referring to a frame, as described in the Frame object.
windowReference is a valid way of referring to a window, as described in the window object.
Button object, Checkbox object, FileUpload object, Frame object, Password object, Radio object, Reset object object, Select object, Submit object, Text object, Textarea object, window object
The following example removes focus from the password element userPass:
userPass.blur()
This example assumes that the password is defined as
<INPUT TYPE="password" NAME="userPass">
focus method, select method
Method. Causes a string to be displayed as bold as if it were in a <B> tag.
stringName.bold()
stringName is any string or a property of an existing object.
Use the bold method with the write or writeln methods to format and display a string in a document.
The following example uses string methods to change the formatting of a string:
var worldString="Hello, world"
document.write(worldString.blink())
document.write("<P>" + worldString.bold())
document.write("<P>" + worldString.italics())
document.write("<P>" + worldString.strike())
The previous example produces the same output as the following HTML:
<BLINK>Hello, world</BLINK>
<P><B>Hello, world</B>
<P><I>Hello, world</I>
<P><STRIKE>Hello, world</STRIKE>
blink, italics, strike methods
booleanObjectName = new Boolean(value)
booleanObjectName.propertyName
propertyName is one of the properties listed below.
The Boolean object is a built-in JavaScript object.
The Boolean object has the following properties:
Property | Description |
---|---|
prototype |
Lets you add a properties to a Boolean object.
|
The following examples create Boolean objects with an initial value of false:
bNoParam = new Boolean()
bZero = new Boolean(0)
bNull = new Boolean(null)
bEmptyString = new Boolean("")
bfalse = new Boolean(false)
The following examples create Boolean objects with an initial value of true:
btrue = new Boolean(true)
btrueString = new Boolean("true")
bfalseString = new Boolean("false")
bSuLin = new Boolean("Su Lin")
Property. A string specifying the width, in pixels, of an image border.
imageName.border
imageName is either the name of an Image object or an element in the images array.
border is a read-only property.
The following function displays the value of an image's border property if the value is not zero.
function checkBorder(theImage) {
if (theImage.border==0) {
alert('The image has no border!')
}
else alert('The image's border is ' + theImage.border)
}
height, hspace, vspace, width properties
Object. A pushbutton on an HTML form.
To define a button, use standard HTML syntax with the addition of JavaScript event handlers:
<INPUT
TYPE="button"
NAME="buttonName"
VALUE="buttonText"
[onBlur="handlerText"]
[onClick="handlerText"]
[onFocus="handlerText"]>
To use a Button object's properties and methods:
1. buttonName.propertyName
2. buttonName.methodName(parameters)
3. formName.elements[index].propertyName
4. formName.elements[index].methodName(parameters)
buttonName is the value of the NAME attribute of a Button object.
propertyName is one of the properties listed below.
methodName is one of the methods listed below.
A Button object on a form looks as follows:
A Button object is a form element and must be defined within a <FORM> tag.
The Button object has the following properties:
Property | Description |
---|---|
form property |
Specifies the form containing the Button object
|
name |
Reflects the NAME attribute |
type |
Reflects the TYPE attribute |
value |
Reflects the VALUE attribute |
The Button object has the following methods:
<INPUT TYPE="button" VALUE="Calculate" NAME="calcButton"
onClick="calcFunction(this.form)">
Form object, Reset object, Submit object
Property. Returns the name of the function that invoked the currently executing function.
functionName.caller
Function object, any user-defined function (see See "Defining and calling functions")
The caller property is a reference to the calling function, so
functionName.toString()
--the decompiled canonical source form
of the function.
The following code checks the value of a function's caller property.
function myFunc() {
if (myFunc.caller == null) {
alert("The function was called from the top!")
} else alert("This function's caller was " + myFunc.caller)
}
Method. Returns the least integer greater than or equal to a number.
Math.ceil(number)
number is any numeric expression or a property of an existing object.
The following function returns the ceil value of the variable x:
function getCeil(x) {
return Math.ceil(x)
}
If you pass getCeil the value 45.95, it returns 46; if you pass it the value -45.95, it returns -45.
floor method
Method. Returns the character at the specified index.
stringName.charAt(index)
stringName is any string or a property of an existing object.
index is any integer from zero to stringName.length - 1, or a property of an existing object.
The following example displays characters at different locations in the string "Brave new world":
var anyString="Brave new world"
document.write("The character at index 0 is " + anyString.charAt(0))
document.write("The character at index 1 is " + anyString.charAt(1))
document.write("The character at index 2 is " + anyString.charAt(2))
document.write("The character at index 3 is " + anyString.charAt(3))
document.write("The character at index 4 is " + anyString.charAt(4))
indexOf, lastIndexOf, split methods
To define a checkbox, use standard HTML syntax with the addition of JavaScript event handlers:
<INPUT
TYPE="checkbox"
NAME="checkboxName"
VALUE="checkboxValue"
[CHECKED]
[onBlur="handlerText"]
[onClick="handlerText"]
[onFocus="handlerText"]>
textToDisplay
textToDisplay specifies the label to display beside the checkbox.
To use a Checkbox object's properties and methods:
1. checkboxName.propertyName
2. checkboxName.methodName(parameters)
3. formName.elements[index].propertyName
4. formName.elements[index].methodName(parameters)
checkboxName is the value of the NAME attribute of a Checkbox object.
propertyName is one of the properties listed below.
methodName is one of the methods listed below.
A Checkbox object on a form looks as follows:
A Checkbox object is a form element and must be defined within a <FORM> tag.
The Checkbox object has the following properties:
The Checkbox object has the following methods:
<B>Specify your music preferences (check all that apply):</B>
<BR><INPUT TYPE="checkbox" NAME="musicpref_rnb" CHECKED> R&B
<BR><INPUT TYPE="checkbox" NAME="musicpref_jazz" CHECKED> Jazz
<BR><INPUT TYPE="checkbox" NAME="musicpref_blues" CHECKED> Blues
<BR><INPUT TYPE="checkbox" NAME="musicpref_newage" CHECKED> New Age
<HTML>
<HEAD>
<TITLE>Checkbox object example</TITLE>
</HEAD>
<SCRIPT>
function convertField(field) {
if (document.form1.convertUpper.checked) {
field.value = field.value.toUpperCase()}
}
function convertAllFields() {
document.form1.lastName.value = document.form1.lastName.value.toUpperCase()
document.form1.firstName.value = document.form1.firstName.value.toUpperCase()
document.form1.cityName.value = document.form1.cityName.value.toUpperCase()
}
</SCRIPT>
<BODY>
<FORM NAME="form1">
<B>Last name:</B>
<INPUT TYPE="text" NAME="lastName" SIZE=20 onChange="convertField(this)">
<BR><B>First name:</B>
<INPUT TYPE="text" NAME="firstName" SIZE=20 onChange="convertField(this)">
<BR><B>City:</B>
<INPUT TYPE="text" NAME="cityName" SIZE=20 onChange="convertField(this)">
<P><INPUT TYPE="checkBox" NAME="convertUpper"
onClick="if (this.checked) {convertAllFields()}"
> Convert fields to upper case
</FORM>
</BODY>
</HTML>
Form object, Radio objects
Property. A Boolean value specifying the selection state of a Checkbox object or radio button.
1. checkboxName.checked
2. radioName[index].checked
radioName is the value of the NAME attribute of a Radio object.
index is an integer representing a radio button in a Radio object.
function stateChecker() {
var checkedButton = ""
for (var i in document.musicForm.musicType) {
if (document.musicForm.musicType[i].checked=="1") {
checkedButton=document.musicForm.musicType[i].value
}
}
}
defaultChecked property
Method. Cancels a timeout that was set with the setTimeout method.
clearTimeout(timeoutID)
timeoutID is a timeout setting that was returned by a previous call to the setTimeout method.
Frame object, window object
See the description for the setTimeout method.
See the examples for the setTimeout method.
setTimeout method
Method. Simulates a mouse-click on the calling form element.
1. buttonName.click()
2. radioName[index].click()
3. checkboxName.click()
radioName is the value of the NAME attribute of a Radio object or an element in the elements array.
index is an integer representing a radio button in a Radio object.
Button, Checkbox, Radio, Reset object, Submit object
The effect of the click method varies according to the calling element:
The click method does not trigger an object's onClick event handler.
document.musicForm.musicType[0].click()
The following example toggles the selection status of the newAge checkbox on the musicForm form:
document.musicForm.newAge.click()
Method. Closes an output stream and forces data sent to layout to display.
document.close()
function windowWriter1() {
var myString = "Hello, world!"
msgWindow.document.open()
msgWindow.document.write(myString + "<P>")
msgWindow.document.close()
}
open (document object), write, writeln methods
Method. Closes the specified window.
windowReference.close()
windowReference is a valid way of referring to a window, as described in the window object.
Any of the following examples closes the current window:
window.close()
self.close()
close()
The following example closes the messageWin window:
messageWin.close()
This example assumes that the window was opened in a manner similar to the following:
messageWin=window.open("")
closed property; open (window object) method
Property. Specifies whether a window is closed.
[windowReference.]closed
windowReference is a valid way of referring to a window, as described in the window object.
closed is a read-only property.
win1=window.open('opener1.html','window1','width=300,height=300')
...
if (win1.closed)
function1()
else
function2()
if (window.opener.closed)
function1()
else
function2()
close (window object), open (window object) methods
imageName.complete
imageName is either the name of an Image object or an element in the images array.
complete is a read-only property.
<B>Choose an image:</B>
<BR><INPUT TYPE="radio" NAME="imageChoice" VALUE="image1" CHECKED
onClick="document.images[0].src='f15e.gif'">F-15 Eagle
<BR><INPUT TYPE="radio" NAME="imageChoice" VALUE="image2"
onClick="document.images[0].src='f15e2.gif'">F-15 Eagle 2
<BR><INPUT TYPE="radio" NAME="imageChoice" VALUE="image3"
onClick="document.images[0].src='ah64.gif'">AH-64 Apache
<BR><INPUT TYPE="button" VALUE="Is the image completely loaded?"
onClick="alert('The value of the complete property is '
+ document.images[0].complete)">
<BR>
<IMG NAME="aircraft" SRC="f15e.gif" ALIGN="left" VSPACE="10"><BR>
Method. Displays a Confirm dialog box with the specified message and OK and Cancel buttons.
confirm("message")
message is any string or a property of an existing object.
A confirm dialog box looks as follows:
Use the confirm method to ask the user to make a decision that requires either an OK or a Cancel. The message argument specifies a message that prompts the user for the decision. The confirm method returns true if the user chooses OK and false if the user chooses Cancel.
You cannot specify a title for a confirm dialog box, but you can use the open method to create your own "confirm" dialog. See open (window object).
function confirmCleanUp() {
if (confirm("Are you sure you want to quit this application?")) {
cleanUp()
}
}
<INPUT TYPE="button" VALUE="Quit" onClick="confirmCleanUp()">
Property. Specifies the function that creates an object prototype.
objectType.constructor
objectType is the name of a constructor or function specifying an object type.
constructor is a property of any prototype object (see "Creating new objects").
function Tree(name) {
this.name=name
}
theTree = new Tree("Redwood")
document.writeln("<B>theTree.constructor is</B> " +
theTree.constructor + "<P>")
This example displays the following output:
theTree.constructor is function Tree(name) { this.name = name; }
prototype property; "Creating new objects"
document.cookie
Use string methods such as substring, charAt, indexOf, and lastIndexOf to determine the value stored in the cookie. See the Appendix D, "Netscape cookies" for a complete specification of the cookie syntax.
You can set the cookie property at any time.
Wdy, DD-Mon-YY HH:MM:SS GMT
This format represents the following values:
For example, a valid cookie expiration date is
expires=Wednesday, 09-Nov-99 23:12:40 GMT
function RecordReminder(time, expression) {
// Record a cookie of the form "@<T>=<E>" to map
// from <T> in milliseconds since the epoch,
// returned by Date.getTime(), onto an encoded expression,
// <E> (encoded to contain no white space, semicolon,
// or comma characters)
document.cookie = "@" + time + "=" + expression + ";"
// set the cookie expiration time to one day
// beyond the reminder time
document.cookie += "expires=" + cookieDate(time + 24*60*60*1000)
// cookieDate is a function that formats the date
//according to the cookie spec
}
Hidden object
Method. Returns the cosine of a number.
Math.cos(number)
The cos method returns a numeric value between -1 and one, which represents the cosine of the angle.
The following function returns the cosine of the variable x:
function getCos(x) {
return Math.cos(x)
}
acos, asin, atan, atan2, sin, tan methods
Property. A string specifying the complete URL of the current history entry.
history.current
current is a read-only property.
if (history.current.indexOf("netscape.com") != -1) {
myFunction(history.current)
}
next, previous properties; "Using data tainting for security"
file: /Techref/language/JAVA/script/ref_a-c.htm, 135KB, , updated: 2009/2/2 13:27, local time: 2024/11/25 12:37,
13.58.201.240:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://ecomorder.com/techref/language/JAVA/script/ref_a-c.htm"> Navigator JavaScript reference </A> |
Did you find what you needed? |
Welcome to ecomorder.com! |
Welcome to ecomorder.com! |
.