Example Glossary

CONTENTS

THIS GLOSSARY IS FOR A QUICK LOOK-UP of different keywords, statements, and terms used in standard ECMA-262 JavaScript, with clear examples provided. You will not find words that either Microsoft or Netscape developed outside the ECMA-262 standard, no matter how helpful these terms are. Also, you will not find a standard "Reference" section here. If that's what you want, you can find the mother of all JavaScript references at http://developer.netscape.com/evangelism/docs/reference/ecma/Ecma-262.pdf.

The European Computer Manufacturer's Association (ECMA) is the definitive authority on JavaScript, and its 188-page reference section includes all of the technical material about JavaScript. (See also http://www.ecma.ch.)

This glossary's function is to make it easy to find a term, see what it does, and see an example of how to write it. It's quick and simple, and it will help you get a statement correctly written. To keep this glossary clear, the examples are short and to the point, and the definitions are nontechnical but functional. Some examples are shorter than others, depending on what you need to use them effectively. Objects and their methods are listed by the nature of the object and are followed by a property or method. For example, the string object (which is almost never called "string") will include string.length. Typically, the length of a string will be found in an iterative loop such as this:

for(counter=0;counter < cusName.length; counter++) {.... 

The string's name is cusName, which is a far more likely string name than string. However, to make it simple to find what properties and methods are associated with strings, I use string.xxxx to make it simple to find things alphabetically in the glossary. Moreover, some properties and methods are part of an object of an object. For example, form has several different associated elements, such as Input, so you will see "formInput.text" and "formInput.button" entries because they are all types of <input> options. Also, several objects have similar or identical properties. For example, you will find "history.length" and "array.length" entries, among others. So, to help keep things clear, it makes more sense to alphabetize the objects using clear names rather than the properties or methods that might occur in several different objects.

alert(value)

Opens an alert box on the screen in the browser.

Example:

var fname="Linda" alert("Hello " + fname) 
anchor

Creates an anchor in a document.

Example:

var fish = "trout" document.write(fish.anchor("fresh_water")) 
applet

An applet in the current HTML page. May be expressed as a name or an array.

Example:

document.applets[3].hide( ) 
Array( )

A multielement array object. The keyword Array( ) is a constructor object. Optionally, you can enter the number of array elements.

Example:

var group=new Array(5); var gang = new Array("Fuzzy", "Willie", "Sleepy", "Homer") 
array.concat( )

Adds new elements that do not become a permanent part of the array.

Example:

var dogs = new Array("Rottie", "Sheltie") dogs.concat("Swissy", "Beagle") alert(dogs.concat("Swissy", "Beagle")) //Output = Rottie, Sheltie, Swissy, Beagle 
array.join( )

Elements in an array are made into a single concatenated string with an optional separator.

Example:

var dogs = new Array("Rottie", "Sheltie") alert(dogs.join(" ")) //Output = Rottie Sheltie 
array.length

Returns the length of an array.

Example:

var cities = new Array ("Paris", "London", "Los Angeles", "Bloomfield"); var nCities = cities.length; //nCities = 4 
array.reverse( )

Reverses the order of elements in an array.

Example:

var geekLetters = new Array("alpha", "beta", "gamma"); alert(geekLetters.reverse( )); //Output = gamma, beta, alpha 
array.slice(s,e)

Returns a segment of an array beginning with s and ending with e.

Example:

var cities = new Array ("Paris", "London", "Los Angeles", "Bloomfield"); var nCities = cities.splice(1,2); alert(nCities) //Output= London, Los Angeles 
array.sort( )

Puts array elements into alphabetical order.

Example:

var cities = new Array ("Paris", "London", "Los Angeles", "Bloomfield"); var nCities = cities.sort( ); //nCities = Bloomfield,London, Los Angeles, Paris 
array.toString( )

Converts all array elements to a single string.

Example:

var deli = new Array ("Bagels", "Lox", "Dill Pickles", "Cream Cheese"); var food = deli.toString( ); // food = single string   Bagels,Lox,Dill Pickles,Cream Cheese 
button
See [formInput.button.value]
checkbox
See [formInput.checkbox.value]
clearTimeout( )
See [window.clearTimeout( )]
close( )
See [window.close( )]
closed
See [window.closed]
confirm( )
See [window.confirm(q)]
Date( )

Date and time object.

Example:

var today=new Date( ); document.write(today); //Screen shows: Sat Jul 28 10:52:44 GMT-0400 (2001) 
Date.getDate( )

Day of the month, as a number between 1 and 31.

Example:

var today=new Date( ); alert(today.getDate( )); //Value between 1 and 31 
Date.getDay( )

Day of the week, expressed as a value 0 to 6, with Sunday being 0.

Example:

var today=new Date( ); alert(today.getDay( )); //Value between 0 and 6  
Date.getFullYear( )

Returns the current year.

Example:

var today=new Date( ); alert(today.getFullYear( )); //Actual year such as 2003 
Date.getHours( )

Returns 24 hours, from 0 to 23 (midnight is 0).

Example:

var today=new Date( ); alert(today.getHours( )); //2 PM returns 14 
Date.getMilliseconds( )

Returns 0 to 999 in milliseconds.

Example:

var today=new Date( ); var now = today.getMilliseconds( ) document.write(now); //Enter script and press Re-load on browser to see changes 
Date.getMinutes( )

Gets the current minute of the hour, between 0 and 59.

Example:

var today=new Date( ); var now = today.getMinutes( ) document.write(now); 
Date.getMonth( )

Gets the current month, from 0 to 11 (January is 0).

Example:

var today=new Date( ); var now = today.getMonth( ) document.write(now); 
Date.getSeconds( )

Returns the current seconds, 0 to 59.

Example:

var today=new Date( ); var now = today.getSeconds( ) document.write(now); 
Date.getTime( )

The time between the Date( ) value and January 1, 1970.

Example:

var today=new Date(); var now = today.getTime( ) document.write(now); //Some value like 996335075147 appears 
Date.getTimezoneOffset( )

The difference, in minutes, in local time and UTC (universal time, or Greenwich Mean Time).

Example:

var today=new Date( ); var now = today.getTimezoneOffset( ) document.write(now/60); //Shows difference in hours because to division by 60. 
Date.getUTCDate( )

Returns the UTC day of month (1 31).

Example:

var today=new Date( ); var now = today.getUTCDate( ) 
Date.getUTCDay( )

Returns the UTC day of week (0 6).

Example:

var today=new Date( ); var now = today.getUTCDay( ) 
Date.getUTCFullYear( )

Returns the UTC year (such as 2003).

Example:

var today=new Date( ); var now = today.getUTCFullYear( ) 
Date.getUTCHours( )

Returns UTC hours (0 23).

Example:

var today=new Date( ); var now = today.getUTCHours( ); 
Date.getUTCMilliseconds( )

Returns milliseconds of a UTC date.

Example:

var today=new Date( ); var now = today.getUTCMilliseconds( ) 
Date.getUTCMinutes( )

Returns UTC minutes (0 59).

Example:

var today=new Date( ); var now = today.getUTCHours( ); 
Date.getUTCMonth( )

Returns the UTC month (0 11).

Example:

var today=new Date( ); var now = today.getUTCMonth( ); 
Date.getUTCSeconds( )

Returns UTC seconds (0 59).

Example:

var today=new Date( ); var now = today.getUTCSeconds( ); 
Date.getYear( )

This function contains bugs. Use getFullYear( ) instead.

date.setDate( )

Sets the day of the month between 01 and 31. (It does not change your computer's internal clock.)

Example:

var today=new Date( ); today.setDate(31); var myTime=today.getDate( ); //myTime = 31 no matter what the day is 
date.setFullYear( )

Sets the year to a specified year.

Example:

var today=new Date( ); var now=today.getFullYear( ); today.setFullYear(1992); alert("That was " + (now - today.getFullYear()) + " years ago." ); 
date.setHours( )

Sets the hours of the day from 0 to 23.

Example:

var today=new Date( ); today.setHours(15); document.write(today.getHours( )); 
date.setMilliseconds(m)

Sets m to an integer between 0 and 999. (Values greater than 999 reduce to the three rightmost values; 5432 reverts to 432.)

Example:

var today=new Date( ); today.setMilliseconds(999); document.write(today.getMilliseconds( )); 
date.setMinutes( )

Sets minutes between 0 and 59.

Example:

var today=new Date( ); today.setMinutes(43); document.write(today.getMinutes( )); 
date.setMonth( )

Sets the month, between 0 and 11.

Example:

var today=new Date( ); today.setMonth(5); //Sets June document.write(today.getMonth( )); 
date.setSeconds( )

Sets seconds, between 0 and 59.

Example:

var today=new Date( ); today.setSeconds(54); document.write(today.getSeconds( )); 
date.setTime( )

Sets the time in milliseconds relative to January 1, 1970.

Example:

var today=new Date( ); today.setDate(996338910155); //Sets July 28, 2001 
date.setUTCDate( )

Sets the UTC day of the month (1 31).

Example:

var today=new Date( ); today.setUTCDate(22); document.write(today.getUTCDate( )); 
date.setUTCFullYear( )

Sets the UTC full year (such as 2020).

Example:

var today=new Date( ); today.setUTCFullYear(2002) 
date.setUTCHours( )

Sets UTC hours (0 23).

Example:

var today=new Date( ); today.setUTCHours(17) 
date.setUTCMilliseconds( )

Sets UTC milliseconds (0 999).

Example:

var today=new Date( ); today.setUTCMilliseconds(999); document.write(today.getUTCMilliseconds( )); 
date.setUTCMinutes( )

Sets minutes from 0 to 59.

Example:

var today=new Date( ); today.setUTCMinutes(45); 
date.setUTCMonth( )

Sets UTC months from 0 to 11.

Example:

var today=new Date( ); today.setUTCMonth(5); 
date.setUTCSeconds( )

Sets UTC seconds from 0 to 59.

Example:

var today=new Date( ); today.setUTCSeconds(5); 
date.toLocaleDateString( )

Conversion of date to string.

Example:

var today=new Date( ); var ls=today.toLocaleString( ); document.write(ls); //formatted as Jul 28 14:59:29 2001 
date.toString( )

Conversion of date to string. Note differences in format between toString( ) and toLocaleString( ).

Example:

var today=new Date( ); var ls=today.toString( ); document.write(ls); //formatted as Sat Jul 28 15:03:55 GMT-0400 (2001) 
date.toUTCString( )

Conversion of data to a UTC string.

Example:

var today=new Date( ); var ls=today.toUTCString( ); document.write(ls); //formatted as Sat, 28 Jul 2001 19:06:12 GMT 
date.valueOf( )

Date converted to a number.

Example:

var today=new Date( ); var ls=today.valueOf( ); document.write(ls); 
document

A web (HTML) page. References to the document object are to its properties and methods. It may also be referenced as part of a window.

Example:

window.document 
document.alinkColor

Color when link is selected.

Example:

document.alinkColor="green"; 
document.anchors[ ]

Anchors in the current document as the named object or element.

Example:

var alpha=document.anchor[4] 
document.applets[ ]

Reference to applets in the current document as a named object or element.

Example:

var alpha=document.applets[0] 
document.bgColor

Background color of a page.

Example:

document.bgColor="'#ff00ff" 
document.close( )

Closes an open document when writing HTML code using JavaScript.

Example:

document.close( ) 
document.cookie

The cookie on an HTML page.

Example:

var crumbs = document.cookie; //Read value of cookie into variable "crumbs" 
document.domain

Specifies the domain from which one window can read another window.

Example:

document.domain="sandlight.com"; 
document.embeds[ ]

Array of objects of data embedded in an HTML page.

Example:

var embedBugs = document.embeds.length 
document.fgColor

A document's default text color.

Example:

document.fgColor="cornflowerblue"; 
document.forms[ ]

The form object of an HTML page. All forms constitute elements of a form's array object.

Example:

document.forms[0].reset( ); 
document.images[ ]

The image object of an HTML page. All images on the page are part of the image object array.

Example:

var sizeImages=document.images.length; 
document.lastModified

Date of last modification.

Example:

var fixUp = document.lastModified; document.write("Last modified by Al => " + fixUp); 
document.linkColor

Sets unvisited link color.

Example:

document.linkColor="peru" 
document.links

An HTML page's link array object. (Properties of a page's links can be displayed after a page is fully loaded.)

Example:

function showMe( ) { var alpha=document.links.length; alert(alpha); } 
document.location

Access URL.

Example:

document.location="http://www.sandlight.com"; //link to www.sandlight.com 
See also [document.URL
document.open( )

Opens a new document. Typically used for writing HTML pages from script in JavaScript.

Example:

document.open( ); 
document.plugins[ ]
See [document.embeds[ ]]
document.referrer

The page that linked to the current page. Requires a link from a previous page.

Example:

var homie = document.referer; document.location=homie; 
document.title

Current HTML page's title.

Example:

alert(document.title); 
document.URL

URL of specified page. (Replaces document.location.)

Example:

Document.URL="http://www.sandlight.com" 
document.vlinkColor

Specifies the color of visited links.

Example:

document.vlinkColor="#ff00ff"; 
document.write( )

Used for both sending text to a page and writing an HTML document.

Example:

document.write("<b>'This is bold' </b>"); 
document.writeln( )

Same as document.write, with an added carriage return.

Example:

document.writeln("This is the first line.") document.writeln("This is on another line.") 
escape( )

Codes string for sending in a form or email.

Example:

var alpha="Happy Birthday, Pat"; var sendMe=escape(alpha); document.write(sendMe); //Returns = Happy%20Birthday%2C%20Pat 
eval( )

Evaluates an expression and puts it into a string.

Example:

var alpha=eval(Math.sqrt(16)); alert(alpha); //Output = 4 
form

Input form treated as an array object in JavaScript.

Example:

document.forms[2].reset( ) 
form.elements[ ]

All of the input and textarea elements in a form container. Each is treated as an element of form array object and is addressed by element name or number.

Example:

var output = document.forms[0].elements[2].value; var output = document.customers.lastNames.value; 
form.length

The numbers of elements in a form container.

Example:

var howLong = document.forms[3].length;//Number of elements in form. var myForm = document.forms.length; //Number of forms in document 
form.reset( )

Clears all data from a form.

Example:

Function clearEm( ) { document.forms[0].reset( ); } 
form.reset.value

Current value of a Reset button. The value is placed in an <input> tag.

Example:

var alpha=document.forms[0].wipe.value; //wipe is name of reset button 
form.textarea.value

Returns the contents of a textarea.

Example:

var Texas = document.forms[0].fred.value; //The text area's name is "fred." //The variable Texas contains the contents of the textarea //named "fred." 
formInput.button.value

Returns or changes value assigned to a button.

Example:

var button = document.forms[0].butNow.value; //Returns the name on the button! 
formInput.checkbox.checked

Generates a Boolean value on whether a check box is checked.

Example:

//Checkbox object named "chuck" if (document.forms[0].chuck.checked) {.... 
formInput.checkbox.defaultChecked

Boolean read-only to determine whether a check box is initially checked.

Example:

var alpha = document.forms[0].chuck.defaultChecked; if(alpha) { alert("It's checked from the beginning.") } 
formInput.checkbox.value

Returns on unless a specific value is assigned in the Value attribute in the <input> container.

Example:

var alpha = document.forms[0].chuck.value 
formInput.name

Returns the name of a form element.

Example:

var alpha=document.forms[0].elements[4].name; //Places the name of the fifth element into alpha 
formInput.password.value

The value of a password, as defined in the value attribute of the form element.

Example:

var openUp = document.forms[0].elements[4].value; if(openUp=="reallySecret") {.... 
formInput.radio.checked

A Boolean value to determine whether a radio button is checked.

Example:

var alpha=document.forms[0].elements[2].checked; if(alpha) { alert(":It's checked"); } //elements[2] is one of three radio buttons 
formInput.radio.value

The value of the value attribute is assigned in the <input> tag in the HTML page. If no value is assigned, the value returned is on, whether the button is checked or not. While all the names of radio buttons in a form should be the same, the values are typically different.

Example:

var alpha=document.forms[0].elements[3].value; //elements[3] is a radio button input element 
formInput.submit.value

The value of the Submit button assigned in the <input> tag, or Submit Query if no value is assigned.

Example:

var alpha=document.forms[0].jack.value; //"jack" is the name of the submit button. 
formInput.text.value

The current value of a text field or a value to be assigned.

Example:

var alpha=document.forms[0].announce.value; alpha = "Read this."; //String assigned to text field "announce". 
formInput.type

Returns select-one or select multiple, depending on the contents of the <select> tag.

Example:

var alpha=document.forms[0].nancy.type; alert(alpha); //name is the select element's name. 
formInput.value

The value of a form input element.

Example:

var fullName=document.forms[0].name.value; 
forms[n].reset( )

Clears all text forms.

Example:

<body onLoad=document.forms[0].reset( ) 
formSelect.length

The length refers to the number of options in a select property.

Example:

var numOps=document.forms[0].chooser.length; alert("You have " + numOps + " options."); //"chooser" is the name of the select form element. 
formSelect.options

Options properties in a select object.

Example:

var selections=document.forms[0].chooser; var selOp=selections.options.length; 
formSelect.selectedIndex

Element value of the selected option.

Example:

var selections=document.forms[0].chooser; //chooser is select obj. var selOp=selections.selectedIndex; alert(selOp)//Element value of selected options appears 
formSelect.type

Either select one or select-multiple types.

Example:

var selections=document.forms[0].chooser; var selType=selections.type alert(selType) //chooser is select object 
frame
See [window.frames[ ]]
function

A delayed operation fired by an event handler.

Example:

function showView(msg) { alert(msg); //Statements go here. } //Function terminated by closing curly brace 
function.toString( )

Places the ouput of a function into a string format.

Example:

function showMe(msg) { alert(msg) } var buzz=showMe("I am a function").toString; alert(buzz); 
history.back( )

Goes to the previously visited URL that was viewed before the current page in the current session.

Example:

window.history.back( ); 
history.forward( )

Goes to the previously visited URL that was viewed after the current page in the current session.

Example:

window.history.forward( ) 
history.go( )

Goes forward or backward a specified number of pages. Positive numbers go forward, and negative numbers go backward.

Example:

window.history.go (2) // Two pages forward window.history.go (-3) // Three pages back 
image

Reference to an image in an HTML page. All embedded images are considered part of an image array.

Example:

var tUp=new Image() tUp.src="targetUp.jpg" function showTarget() { document.images[1].src=tUp.src } 
image.border

Returns the width of the border specified in an <img> tag.

Example:

var bdr=document.images[0].border; alert(bdr); //bdr is the width of the border 
image.complete

Boolean value of whether the browser has completed loading an image.

Example:

var upYet=document.images[1].complete; if(upYet) { alert("Image is loaded"); } 
image.height

Returns the value of the height HTML attribute.

Example:

var grH = document.flame.height //flame = graphic name attribute in <img> tag. 
image.hspace

Returns the number of blank pixels on the left and right of the image.

Example:

var xPixes = document.flame.hspace //flame = graphic name attribute in <img> tag. 
image.name

Name attribute of an <img> tag.

Example:

//Name in <img> tag is "flower" document.flower 
image.src

The filename (or URL) of the image to appear in the browser. This can be changed to allow different images to occupy the same position. The first URL is defined in the HTML <img> tag in the SRC attribute.

Example:

var rollin= new Image( ); rollin.src="pix/nextOne.jpg"; document.images[3].src=rollin.src; 
image.vsapce

Returns the number of blank pixels above and below an image.

Example:

var vPixes = document.flame.vspace //flame = graphic name attribute in <img> tag. 
image.width

Returns the width of the image set in the <img> tag's Width attribute.

Example:

var w=document.images[0].width; 
isFinite(n)

Returns a Boolean value of whether the number is finite.

Example:

var littleNumber = 123 if(isFinite(littleNumber)) { alert("We can afford it!") } 
isNaN(v)

Returns a Boolean value of whether the value is a number.

Example:

if(isNaN(price) { alert("Your entry is not a number) } 
link

A link in an HTML page. Each link is an element in the links array belonging to the document object.

Example:

function numLinks( ) { var nl = document.links.length; alert("You have " + nl " links in your page."); } 
location

The browser location and a control of that location. Each of the following properties of location make up a part of a complete URL. The following semificticious URL contains all of the properties in location: http://www.sandlight.com:1944/js/seeker.html?script#side.

location.hash #side

location.host www.sandlight.com:1944

location.hostname www.sandlight.com

location.href The entire URL

location.pathname js/seeker.html?script#side

location.port 1944

location.protocol http://

location.search ?script

All of the location properties are read/write and can be used to access any of the properties of the location object.

See also [document.location]
location.reload( )

Reloads the current page.

Example:

Location.reload( ) 
location.replace()

Replaces the current page with a new page, but without keeping a history.

Example:

location.replace(http://www.sandlight.com) 

Math Constants

All math constants have a single value, as noted here. You can place them into variables or use the constants themselves wherever needed. Use the following example format:

var cirArea = Math.PI * (radius * radius) 

Table G.1 shows the constants, their meaning, and their value.

Table G.1. JavaScript Math Constants

Name

Meaning

Value

Math.E

Constant e

2.718281828459045

Math.LN10

Constant loge 10

2.302585092994046

Math.LN2

Constant loge 2

.6931471805599453

Math.LOG10E

Constant log10 e

.4342944819032518

Math.LOG2E

Constant log2 e

1.4426950408889634

Math.PI

Constant pi

3.141592653589793

Math.SQRT1_2

Constant 1 divided by the square root of 2

.7071067811865476

Math.SQRT2

Constant square root of 2

1.4142135623730951

Math Functions

All built-in JavaScript math functions expect some type of argument, some with a range. However, their format is the same as for math constants and can be placed into variables or objects, as can other functions. Table G.2 provides the basics on math functions.

Table G.2. Math Functions and Parameters

Name

Meaning

Arguments

Absolute value

Math.abs( )

Any positive or negative number

Math.acos( )

Arc cosine

1.0 to 1.0

Math.asin( )

Arc sine

1.0 to 1.0

Math.atan( )

Arc tangent

Any positive or negative number

Math.ceil( )

Round up number

Any positive or negative number

Math.cos( )

Cosine

Any angle measured in radians*

Math.exp( )

excomputed

Any expression or value to be used as exponent

Math.floor( )

Round down number

Any positive or negative number

Math.log( )

Natural logarithm

Any positive value

Math.max(n1,n2)

Larger of two values

Any two values

Math.min(n1,n2)

Smaller of two values

Any two values

Math.pow(n1,n2)

Computes the power of

First value to the power of the second value

Math.random( )

Returns a random number

Returns a number between 0.0 and 1.0

Math.round( )

Rounds to the nearest whole

Any value

Math.sin( )

Sine

Any angle measured in radians*

Math.sqrt( )

Square root

Any positive number

Math.tan( )

Tangent

Any angle measured in radians*

To convert an angle to a radian, use this method:

var radian = angle * (Math.PI * 2) / 360 
navigator

Browser object (not just Netscape Navigator).

navigator.appCodeName

Returns Mozilla for both IE and NN.

Example:

var ncode=navigator.appCodeName alert(ncode) //See Mozilla! 
navigator.appName

Returns browser name (Microsoft Internet Explorer or Netscape).

Example:

var nName=navigator.appName alert(nName) 
navigator.appVersion

Returns the version of the browser. However, both Netscape and Microsoft have version numbers that do not match the version on their browsers. Version 6 of IE returns 4.0, and Version 6.1 of NN returns 5.0. Also returns the encryption and platform.

Example:

var nVer=navigator.appVersion alert(nName) 
navigator.javaEnabled( )

Checks to see whether Java is enabled in your current browser.

Example:

if(!navigator.javaEnabled( )) { alert("Enable your browser for Java!") } 
navigator.platform

Returns the platform version (such as Wind32 or MacPPC).

Example:

var nPlat=navigator.platform if(nPlat==Win32) { document.fgcolor="cornflowerblue"; } 
navigator.userAgent

Returns a combination of the code name and version (such as Mozilla/5.0 [Macintosh; U; PPC; en-US; rv:0.9.1] Gecko/20010607 Netscape6/6.1b1).

Example:

var uAgnt = navigator.userAgent; alert(uAgnt); 

Number Constants

Like the math constants, the number constants have fixed values, even though many of the values must be represented by limit values. Table G.3 shows JavaScript's number constants.

Table G.3. Number Constants

Name

Meaning

Value

Number.MAX_VALUE

Largest number possible

1.7976931348623157e+308

Number.MIN_VALUE

Smallest number close to 0

5e-324

Number.NaN

Not-a-number value

Any non-numeric value

Number.NEGATIVE_INFINITY

A negative value greater than the highest value that JavaScript can represent

Negative maximum value plus minimum value

Number.POSITIVE_INFINITY

A positive value greater than the highest value that JavaScript can represent

Positive maximum value plus minimum value

Number Methods

A single Number method is available in JavaScript.

numberObj.toString( )

Converts a number object to a string.

Example:

var valWord=Number.MAX_VALUE; valWord.toString(); 
object

A compound data type in which all other objects inherit the behavior of the object.

Example:

var kennel = new Object( ); kennel.Bigdogs = "Large breed dogs." Kennel.Bigdogs.wolf = "Irish Wolfhounds" 
object.constructor

A read-only reference to a type of object function used as constructor. For example, if an object is used as a constructor, function Object() is returned; if an array is used, function Array() is returned.

Example:

var kennel = new Object( ); document.write(kennel.constructor) //return   function Object( ) { [native code] } 
object.toString( )

Generally an automatic conversion in JavaScript, the method can clarify conversions.

Example:

var hotel = Excelsior.toString( ) //Excelsior is an existing object alert(hotel) 
object.valueOf( )

Returns the object or its primitive value, but usually the object. Typically returns only the object itself. (Rarely used.)

Example:

var showOut = Excelsior.valueOf( ); document.write(showOut) // output=function valueOf( ) { [native code] } 
parseFloat( )

Converts a string to a floating-point number.

Example:

var strNum = "123.45"; var realNum = parseFloat(strNum); //realNum is floating point. 
parseInt( )

Converts a string to an integer (rounded down).

Example:

var strNum = "123.45"; var intNum = intFloat(strNum); 
screen.availHeight

Returns the vertical screen size in pixels.

Example:

var upScreen = screen.availHeight 
screen.availWidth

Returns the available horizontal screen size in pixels.

Example:

var acrossScreen = screen.availWidth 
screen.colorDepth

Returns the number of bits per pixel. Most modern computers provide 32-bit color.

Example:

var colorPix = screen.colorDepth; 
screen.height

Returns the actual height of the screen. (It is different from availHeight in that it includes all space occupied by icon bars.)

Example:

var allScreenHi = screen.height; 
screen.width

Returns the actual width of the screen.

Example:

var allScreenWide = screen.width; 
string constructor

String objects are created using the String( ) constructor.

Example:

var alpha=new String("Testing"); 
string.big( )

String is output in <big> format.

Example:

var alpha=new String("Testing"); document.write(alpha.big( )); 
string.blink( )

String is output in <blink> format.

Example:

var alpha=new String("Testing"); document.write(alpha.blink( ));" 
string.bold( )

String is output in <b> format.

Example:

var alpha=new String("Testing"); document.write(alpha.bold( )); 
string.charAt(p)

Returns a character in a string at position p.

Example:

var alpha=new String("willie@harlemHome.org");       for(var counter = 0; counter < alpha.length; counter ++) {             if(alpha.charAt(counter) == "@") {             var flag=1;       } //Sets a flag variable if the @ is found } 
string.charCodeAt(p)

Returns the ASCII code of character at position p.

Example:

var alpha = new String("Fancy Characters &%$#@") var asKey = alpha.charCodeAt(19); 
string.concat(s1,s2,sx)

Concatenates strings in an argument to a string object.

Example:

var goof = new String("Mo"); var goofs = goof.concat("Larry","Curly","Shep"); document.write(goofs); 
string.fixed( )

Sets font to <TT> style.

Example:

var alpha=new String("Testing"); document.write(alpha.fixed( )); 
string.fontcolor( )

Assigns a font color to the string.

Example:

var alpha=new String("Color Me!"); document.write(alpha.fontcolor("pink")); 
string.fontsize( )

Assigns a font size using HTML's sizing units (1 7).

Example:

var alpha=new String("I'm Big"); document.write(alpha.fontsize(7)); 
string.fromCharCode(c1,c2,cx)

Creates a string from ASCII or Unicode character values.

Example:

var valentine=String.fromCharCode(76,79,86,69); //Note lack of 'new' document.write(valentine); 
string.indexOf(s,st)

Locates the first occurrence of substring (s) in a string, with an optional start (st) position. The initial position is 0.

Example:

var alpha="Lots of characters." var sIO = alpha.indexOf("char"); document.write("The substring begins at position " + sIO + ".");); 
string.italics( )

Creates an italicized font.

Example:

var alpha=new String("I\'m from Rome!"); document.write(alpha.italics( )); 
string.lastIndexOf(s,st)

Searches for the first occurrence of the substring beginning with the last character. The initial position is 0.

Example:

var alpha="To be or not to be." var lindx = alpha.lastIndexOf("be"); document.write("The last instance of the substring begins at position " + lindx + "."); 
string.length

Returns the length of the string.

Example:

var myName =new String("Rooty Judy Hooty"); var nameNum =myName.length -2 document.write("Her name is " + nameNum + " characters long.") //Subtracted 2 for spaces; 
string.link(url)

Creates a link to the specified URL.

Example:

var hookUp =new String("Treasure Island"); document.write(hookUp.link("http://www.sandlight.com")) 
string.match(re)

Matches a string with one or more regular expressions. (Use Perl regular expression format.)

Example:

var smarties =new String("A generation of genius."); var findIt = smarties.match(/genius/gi); //Gobal and ignore case if(findIt) { document.write("The match is made!") } 
string.replace(re,newStng)

Replaces the contents of a regular expression with a new string. (Use Perl regular expression format.)

Example:

var smarties =new String("A generation of genius."); var replaceIt = smarties.replace(/genius/,"science") document.write(replaceIt) //Returns 'A generation of science.' 
string.search(re)

Searches for a regular expression and returns the starting point.

Example:

var smarties =new String("A generation of genius."); var searchIt = smarties.search(/rat/) document.write("Mr. Rat begins at position " + searchIt +".") 
string.slice(b,e)

Creates a substring beginning at position b and ending at e.

Example:

var pet = new String("Greater Swiss Mountain Dog") var alpine=pet.slice(14,22); document.write(alpine) 
string.small( )

Creates a font in the format of <small> tag in HTML.

Example:

var littleGuy=new String("Chihuahua"); document.write(littleGuy.small( )); 
string.split(d)

Creates an array of strings from a single string, using a delimiter (d) to break the string into elements.

Example:

var farmersMarket=new String("strawberries-cantelope-oranges-apples") var order=farmersMarket.split("-"); document.write(order[3]); 
string.strike( )

Creates strikethrough characters. Based on the <strike> tag in HTML.

Example:

var alpha=new String("Trash"); document.write(alpha.strike( )); 
string.sub( )

Creates a subscript font. Based on the <sub> tag in HTML.

Example:

var alpha=new String("Australia"); document.write("That country is down under " + alpha.sub( )); 
string.substr (b,l)

A substring of a string beginning at b and a length of l.

(This is a subtle but important difference from string.substring( ).)

Example:

var alpha=new String("JavaScript is too cool."); var work=alpha.substr(4,6) +"ing can be hard work." document.write(work); 
string.substring(b,e)

A substring of a string beginning at b and ending at e.

Example:

var alpha=new String("JavaScript is too cool."); var work=alpha.substring(4,9) +"ing can be hard work." document.write(work); 
string.sup( )

Creates a superscript font position. Based on the <sup> tag in HTML.

Example:

var alpha=new String("Arctic Circle"); document.write("That place is way up there " + alpha.sup( )); 
string.toLowerCase( )

Forces all characters in a string to lowercase.

Example:

var alpha=new String("ALL UPPER CASE"); document.write(alpha.toLowerCase( )); 
string.toUpperCase( )

Forces all characters in a string to lowercase.

Example:

var alpha=new String("all lower case"); document.write(alpha.toUpperCase()); 
unescape( )

Changes characters from escape format to decoded format.

Example:

var alpha=new String("Testing%20one"); document.write(unescape(alpha)); 
window

Reference to window object.

Example:

window 
window.alert( )
See [alert(value)]
window.clearInterval( )

Stops actions initiated by setInterval( ).

Example:

window.clearInterval. 
window.clearTimeout( )

Cancels setTimeout( ).

Example:

if (var clocker==4) { window.clearTimeout( ) } 
window.close( )

Closes a specified window or the current window. (See window.open( ).)

Example:

window.close( ); ralph.close( );//ralph is variable name defined in opening. 
window.closed

Tests whether a specified window has been closed.

Example:

var checkWin=smWin.closed; //smWin is a var name defined //when window was opened if(checkWin) {.... 
window.confirm(q)

Presents a question to ask the user. A cancel returns false.

Example:

function checkFirst( ) {           if(window.confirm("You really want to close it?")) {;                 window.close( );           } } 
window.defaultStatus

A read/write string property used to display a message in the window status line.

Example:

var message="Look down here!"; window.defaultStatus=message; //The string "Look down here!" appears in status line. 
window.document

Reference to the current document. (The window term is usually superfluous.)

Example:

var alpha=window.document.forms[2].elements[7].value; 
window.focus( )

Provides keyboard focus to a specified window or frame.

Example:

windows.frames[2].focus( ) 
window.frames[ ]

Reference to frames within a window.

Example:

var numFrames=window.frames.length; 
window.length

Returns the number of frames in a window.

Example:

var numFrames=window.length; 
window.location

URL of the current HTML page loaded.

Example:

var where=window.location; 
See also [location]
window.moveBy(rx,ry)

The number of pixels to move the window to the right and down. (NN requires UniversalBrowserWrite privilege to move off the screen.)

Example:

window.moveBy(40,50) 
window.moveTo(ax,ay)

Moves a window to absolute x,y position. (NN requires UniversalBrowserWrite privilege to move off the screen.)

Example:

window.moveTo(250,400) 
window.name

Name of the window specified in the window.open( ) statement.

Example:

var louise=window.open("","flowers") //"flowers" is the window's name, but to close the window use, //louise.close( ) 
window.open( )

Opens a new window for an existing page or new page. May use variable definition to open a window by naming arguments (url, name, features, and replace). Both major browsers accept the following features:

height location menubar resizable scrollbars status toolbar width 

All arguments are separated by commas, and features are in parentheses and separated by spaces.

Example:

var winName=window.open(" ","services","height=200 width=300",true) 
window.parent

A frame's parent. Usually used in a frame page's script to reference another frame.

Example:

parent.side.document.location="http://www.sandlight.com" //'side' is a frame name in the same parent window. 
window.prompt(q,d)

A prompt window appears with question q and optional default d. User feedback can go into a variable.

Example:

function promptMe( ) { var alpha=window.prompt("How old are you",18); document.forms[0].elements[1].value=alpha; }//The variable alpha contains whatever the user typed in. 
window.resizeBy(rh,rw)

Resizes the window by rh height in pixels and rw width. Function adds pixels to current size. (NN requires UniversalBrowserWrite privilege to set either ah or aw to less than 100 pixels.)

Example:

window.resizeBy(200,100) 
window.resizeTo(ah,aw)

Resizes the window to the absolute height and width specified. (NN requires UniversalBrowserWrite privilege to set either ah or aw to less than 100 pixels.)

Example:

window.resizeTo(580,400) 
window.screen
See [window.screen]
window.scrollTo(x,y)

Scrolls page to x,y coordinates on screen.

Example:

scrollTo(300,200); 
window.self

Used mainly to clarify a window reference to itself.

Example:

window.self 
window.setInterval(script,milliseconds)

Executes a script at an interval set in milliseconds. Both NN and IE use this form. IE does not use the second form, window.setInterval(function,milliseconds, arguments).

Example:

window.setInterval(alpha += 3, 5000); 
window.setTmeout(f,d)

Delays execution (f) for the specified number of milliseconds (d).

Example:

function ready( ) { window.setTimeout("document.reactR.src=react4.src",500); window.setTimeout("document.reactR.src=react1.src",1000); } 
window.status

A read/write string property used to read or add transient message to the status line.

Example:

var temp = "Your frame now is Pictures." window.status = temp; 
window.top

Usually used with frames to reference the top-level window in the frame.

Example:

var topDog=window.top; 
window.window
See [window.self]
CONTENTS


JavaScript Design
JavaScript Design
ISBN: 0735711674
EAN: 2147483647
Year: 2001
Pages: 25

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net