STATEMENTS | |
break | Terminates the current while or for loop |
comment | Comments |
continue | Terminates execution of the block of statements in a while or for loop and continues execution of the loop with the next iteration |
delete | Deletes an object's property or an element of an array |
do...while | Executes its statements until the test condition evaluates to false |
for | Creates a loop that consists of three optional expressions, enclosed in parentheses and separated by semicolons, followed by a block of statements executed in the loop |
for...in | Iterates a specified variable over all the properties of an object |
function | Declares a javascript function name with the specified parameters |
if...else | Executes a set of statements if a specified condition is true or another set of statements if false |
labeled | Provides an identifier that can be used with break or continue to indicate where the program should continue execution |
return | Specifies the value to be returned by a function |
var | Statement that declares a variable |
while | Creates a loop that evaluates an expression and if true, executes a block of statements |
with | Establishes the default object for a set of statements. |
OBJECTS | |
Array | An array |
Boolean | A Boolean |
Date | A date |
Function | Javascript code to be compiled as a function |
Math | Basic math constants and functions |
Number | Numeric values |
Object | Contains the base functionality shared by all javascript objects |
RegExp | Represents a regular expression; also contains static properties that are shared among all regular expression objects |
String | A string |
ARITHMETIC OPERATORS | |
+ | Addition |
++ | Increment |
- | Subtraction |
-- | Decrement |
* | Multiplication |
/ | Division |
% | Modulus |
STRING OPERATORS | |
+ | Concatenate 2 strings |
+= | Concatenate 2 strings and assign the result to the first variable |
LOGICAL OPERATORS | |
&& | AND |
|| | OR |
! | NOT |
ASSIGNMENT OPERATORS | |
= | Assign the value of the second variable to the first variable |
+= | Add 2 numbers and assign the result to the first |
-= | Subtract 2 numbers and assign the result to the first |
*= | Multiply 2 numbers and assign the result to the first |
/= | Divide 2 numbers and assign the result to the first |
%= | Compute the modulus of 2 numbers and assign the result to the first |
COMPARISON OPERATORS | |
== | Equal |
!= | Not equal |
> | Greater than |
>= | Greater than or equal to |
< | Less than |
<= | Less than or equal to |
SPECIAL OPERATORS | |
?: | A simple "if...then...else" |
new | Create an instance of an object type |
this | Refer to the current object |
typeof | Returns a string indicating the type of variable |
void | Specifies an expression to be evaluated without returning a value |
EVENTS | |
onAbort | The user aborts the loading of an image |
onBlur | A form element loses focus or when a window or frame loses focus |
onChange | A select, text, or textarea field loses focus and its value has been modified |
onClick | An object on a form is clicked |
onDblClick | The user double-clicks a form element or a link |
onDragDrop | The user drops an object onto the browser window, such as dropping a file on the browser window |
onError | The loading of a document or image causes an error |
onFocus | A window, frame, or frameset receives focus or when a form element receives input focus |
onKeyDown | The user depresses a key |
onKeyPress | The user presses or holds down a key |
onKeyUp | The user releases a key |
onLoad | The browser finishes loading a window or all of the frames within a FRAMESET tag |
onMouseDown | The user depresses a mouse button |
onMouseMove | The user moves the cursor |
onMouseOut | The cursor leaves an image-map area or link from inside that area or link |
onMouseOver | The cursor moves over an object or area from outside that object or area |
onMouseUp | The user releases a mouse button |
onMove | The user or script moves a window or frame |
onReset | The user resets a form (clicks a Reset button) |
onResize | A window or frame is resized |
onSelect | Text within a text or textarea field is selected |
onSubmit | A form is submitted |
onUnload | The user exits a document |
closed | Specifies whether a window has been closed |
defaultStatus | The default message displayed in the window's status bar |
frames | An array reflecting all the frames in a window |
history | Contains information on the URLs that the client has visited within a window |
innerHeight | The vertical dimension, in pixels, of the window's content area |
innerWidth | The horizontal dimension, in pixels, of the window's content area |
length | The number of frames in the window |
location | Contains information on the current URL |
locationbar | The browser window's location bar |
menubar | The browser window's menu bar |
name | A unique name used to refer to this window |
opener | The window name of the calling document when a window is opened using the open method |
outerHeight | The vertical dimension, in pixels, of the window's outside boundary |
outerWidth | The horizontal dimension, in pixels, of the window's outside boundary |
pageXOffset | The current x-position, in pixels, of a window's viewed page |
pageYOffset | The current y-position, in pixels, of a window's viewed page |
parent | A synonym for a window or frame whose frameset contains the current frame |
personalbar | The browser window's personal bar |
scrollbars | The browser window's scroll bars |
self | A synonym for the current window |
status | A priority or transient message in the window's status bar |
statusbar | The browser window's status bar |
toolbar | The browser window's tool bar |
top | A synonym for the topmost browser window |
window | A synonym for the current window |
alert | Displays an Alert dialog box with a message and an OK button |
back | Undoes the last history step in any frame within the top-level window |
blur | Removes focus from the specified object |
captureEvents | Sets the window or document to capture all events of the specified type |
clearInterval | Cancels a timeout that was set with the setInterval method |
clearTimeout | Cancels a timeout that was set with the setTimeout method |
close | Closes the specified window |
confirm | Displays a Confirm dialog box with the specified message and OK and Cancel buttons |
disableExternalCapture | Disables external event capturing set by the enableExternalCapture method |
enableExternalCapture | Allows a window with frames to capture events in pages loaded from different locations |
find | Finds the specified text string in the contents of the specified window |
focus | Gives focus to the specified object |
forward | Loads the next URL in the history list |
handleEvent | Invokes the handler for the specified event |
home | Points the browser to the URL specified in preferences as the user's home page |
moveBy | Moves the window by the specified amounts |
moveTo | Moves the top-left corner of the window to the specified screen coordinates |
open | Opens a new web browser window |
Prints the contents of the window or frame | |
prompt | Displays a Prompt dialog box with a message and an input field |
releaseEvents | Sets the window to release captured events of the specified type, sending the event to objects further along the event hierarchy |
resizeBy | Resizes an entire window by moving the window's bottom-right corner by the specified amount |
resizeTo | Resizes an entire window to the specified outer height and width |
routeEvent | Passes a captured event along the normal event hierarchy |
scroll | Scrolls a window to a specified coordinate |
scrollBy | Scrolls the viewing area of a window by the specified amount |
scrollTo | Scrolls the viewing area of the window to the specified coordinates, such that the specified point becomes the top-left corner |
setInterval | Evaluates an expression or calls a function every time a specified number of milliseconds elapses |
setTimeout | Evaluates an expression or calls a function once after a specified number of milliseconds has elapsed |
stop | Stops the current download |
The Document object is extremely useful because it contains so much information about the current document, and it can create HTML on-the-fly with its write and writeln methods. The following table lists the properties and methods of the document object, as well as short descriptions of their purpose.
alinkColor | Reflects the ALINK attribute (in the <body> tag). |
anchors | An array listing all of the HTML anchors in the document (<a name>). |
anchor | An anchor object. |
applets | An array containing an entry for each applet in the document |
bgColor | Reflects the value of the BGCOLORattribute. |
cookie | Reflects the value of a Netscape cookie. |
domain | The domain name of the server that served the document |
embeds | An array containing an entry for each plug-in in the document |
fgColor | The value of the TEXT attribute (in the <body> tag). |
forms | An array listing all the forms in the document. |
form | A form object. |
history | An object containing the current browser history (links visited, number of links visited, and link URLs). |
images | An array containing an entry for each image in the document |
lastModified | The date the document was last modified. |
layers | Array containing an entry for each layer within the document |
linkColor | Reflects the LINK attribute of the <body> tag. |
links | An array of all HTML links in the document (<a href> ). |
link | A link object. |
location | The URL of the document. |
plugins | An array containing an entry for each plug-in in the document |
referrer | The URL of the document that called the current document. |
title | Reflects the title of the document. |
URL | The complete URL of a document |
vlinkColor | Reflects the color listed in the VLINKattribute. |
captureEvents | Sets the document to capture all events of the specified type. |
clear | Clears the window of all content. |
close | Closes an output stream and forces data to display. |
getSelection | Returns a string containing the text of the current selection. |
handleEvent | Invokes the handler for the specified event. |
open | Opens a stream to collect the output of write or writeln methods. |
releaseEvents | Sets the window or document to release captured events of the specified type, sending the event to objects further along the event hierarchy. |
routeEvent | Passes a captured event along the normal event hierarchy. |
write | Writes one or more HTML expressions to a document in the specified window. |
writeln | Writes one or more HTML expressions to a document in the specified window and follows them with a newline character. |
This object is created every time JavaScript encounters a <form>...</form> in your HTML documents. It contains all of the information stored in your form and can be used to submit information to a function or back to the server. This Table describes the properties and methods of the Form object.
action | Reflects the HTML ACTION attribute of the <form> tag. |
button | A button object (<input type=button>). |
checkbox | A checkbox object (<input type=checkbox>). |
elements | An array listing all elements in a form. |
encoding | The value of the ENCTYPE attribute (for HTML uploads in Netscape). |
hidden | A hidden object (<input type=hidden>). |
length | The number of elements in the form. |
method | The METHOD attribute of <form>. |
password | A password object (<input type=password>). |
radio | A radio object (<input type=radio>). |
reset | A reset button object. |
select | A select object (<select>...<select>). |
submit | A submit button object. |
target | The TARGET attribute of <form>. |
text | A text object (<input type=text>). |
textarea | A textarea object (<textarea>...</textarea>). |
submit | Submits the form to the location in the ACTION attribute. |
Other objects are built into JavaScript that are not specific to either the browser or the window. The first of these is the String object. This object is very useful because you can use its methods to modify and add HTML modifications without changing the string itself. One item to notice about this object is that you can string together any number of its methods to create multilayers of HTML encoding. For example,
"Hello!".bold().blink() would return <blink><b>Hello!</b></blink>length | The number of characters in the string. |
anchor | Converts string to an HTML anchor. |
big | Encloses string in <big>...</big> . |
blink | Encloses string in <blink>...</blink> . |
bold | Encloses string in <b>...</b> . |
charAt | Returns the character at some index value. Index reads from left to right. If char not found, it returns a -1. |
fixed | Encloses string in <tt>...</tt> . |
fontcolor | Encloses string in <font color=somecolor>...</font> . |
indexOf | Looks for the first instance of some string and returns the index of the first character in the target string, or gives a -1 if not found. |
italics | Encloses string in <i>...</i> . |
lastIndexOf | Same as indexOf, only begins searching from the right to find the last instance of the search string, or -1 if not found. |
link | Converts string into a hyperlink. |
small | Encloses string in <small>...</small> . |
strike | Encloses string in <strike>...</strike> . |
sub | Encloses string in <sub>...</sub> . |
substring | Given a start and end index, returns the string contained by those indices. |
sup | Encloses string in <sup>...</sup> . |
toLowerCase | All uppercase characters are converted to lowercase(UpPeRcAsE becomes uppercase ). |
toUpperCase | All lowercase characters are converted to uppercase. |