please dont rip this site

[Previous reference file]


 

Date

Object. Lets you work with dates and times.

Syntax

To create a Date object:

1. dateObjectName = new Date()
2. dateObjectName = new Date("month day, year hours:minutes:seconds")
3. dateObjectName = new Date(year, month, day)
4. dateObjectName = new Date(year, month, day, hours, minutes, seconds)

To use a Date object:

1. dateObjectName.propertyName
2. dateObjectName.methodName(parameters)

Exceptions: The Date object's parse and UTC methods are static methods that you use as follows:

Date.UTC(parameters)
Date.parse(parameters)

Parameters

dateObjectName is either the name of a new object or a property of an existing object. When using Date properties and methods, dateObjectName is either the name of an existing Date object or a property of an existing object.

month, day, year, hours, minutes, and seconds are string values for form 2 of the syntax. For forms 3 and 4, they are integer values.

propertyName is one of the properties listed below.

methodName is one of the methods listed below.

Property of

None

Implemented in

Description

The Date object is a built-in JavaScript object.

Form 1 of the syntax creates today's date and time. If you omit hours, minutes, or seconds from form 2 or 4 of the syntax, the value will be set to zero.

The way JavaScript handles dates is very similar to the way Java handles dates: both languages have many of the same date methods, and both store dates internally as the number of milliseconds since January 1, 1970 00:00:00. Dates prior to 1970 are not allowed.

Properties

The Date object has the following properties:

Property Description
prototype Lets you add a properties to a Date object.

Methods

The Date object has the following methods:

eval

getDate

getDay

getHours

getMinutes

getMonth

getSeconds

getTime

getTimezoneOffset

getYear

parse

setDate

setHours

setMinutes

setMonth

setSeconds

setTime

setYear

toGMTString

toLocaleString

toString

UTC

valueOf

Event handlers

None.

Examples

The following examples show several ways to assign dates:

today = new Date()
birthday = new Date("December 17, 1995 03:24:00")
birthday = new Date(95,12,17)
birthday = new Date(95,12,17,3,24,0)

See also:


defaultChecked

Property. A Boolean value indicating the default selection state of a checkbox or radio button.

Syntax

1. checkboxName.defaultChecked
2. radioName[index].defaultChecked

Parameters

checkboxName is either the value of the NAME attribute of a Checkbox object or an element in the elements array.

radioName is the value of the NAME attribute of a Radio object.

index is an integer representing a radio button in a Radio object.

Property of

Checkbox, Radio

Implemented in

Navigator 2.0

Tainted?

Yes

Description

If a checkbox or radio button is selected by default, the value of the defaultChecked property is true; otherwise, it is false. defaultChecked initially reflects whether the CHECKED attribute is used within an <INPUT> tag; however, setting defaultChecked overrides the CHECKED attribute.

You can set the defaultChecked property at any time. The display of the checkbox or radio button does not update when you set the defaultChecked property, only when you set the checked property.

Examples

The following example resets an array of radio buttons called musicType on the musicForm form to the default selection state:

function radioResetter() {
   var i=""
   for (i in document.musicForm.musicType) {
      if (document.musicForm.musicType[i].defaultChecked==true) {
         document.musicForm.musicType[i].checked=true
      }
   }
}

See also

checked property


defaultSelected

Property. A Boolean value indicating the default selection state of an option in a Select object.

Syntax

selectName.options[index].defaultSelected
optionName.defaultSelected

Parameters

selectName is either the value of the NAME attribute of a Select object or an element in the elements array.

index is an integer representing an option in a Select object.

optionName is the name of a Select object option created using the Option() constructor.

Property of

Option object (see Select object), options array (see Select object)

Implemented in

Tainted?

Yes

Description

If an option in a Select object is selected by default, the value of the defaultSelected property is true; otherwise, it is false. defaultSelected initially reflects whether the SELECTED attribute is used within an <OPTION> tag; however, setting defaultSelected overrides the SELECTED attribute.

You can set the defaultSelected property at any time. The display of the Select object does not update when you set the defaultSelected property, only when you set the selected or selectedIndex properties.

A Select object created without the MULTIPLE attribute can have only one option selected by default. When you set defaultSelected in such an object, any previous default selections, including defaults set with the SELECTED attribute, are cleared. If you set defaultSelected in a Select object created with the MULTIPLE attribute, previous default selections are not affected.

Examples

In the following example, the restoreDefault function returns the musicType Select object to its default state. The for loop uses the options array to evaluate every option in the Select object. The if statement sets the selected property if defaultSelected is true.

function restoreDefault() {
   for (var i = 0; i < document.musicForm.musicType.length; i++) {
      if (document.musicForm.musicType.options[i].defaultSelected == true) {
         document.musicForm.musicType.options[i].selected=true
      }
   }
}

The previous example assumes that the Select object is similar to the following:

<SELECT NAME="musicType"> 
   <OPTION SELECTED> R&B
   <OPTION> Jazz
   <OPTION> Blues
   <OPTION> New Age
</SELECT>

See also

index, selected, selectedIndex properties


defaultStatus

Property. The default message displayed in the status bar at the bottom of the window.

Syntax

windowReference.defaultStatus

Parameters

windowReference is a valid way of referring to a window, as described in the window object.

Property of

window object

Implemented in

Navigator 2.0

Tainted?

Yes

Description

The defaultStatus message appears when nothing else is in the status bar. Do not confuse the defaultStatus property with the status property. The status property reflects a priority or transient message in the status bar, such as the message that appears when a mouseOver event occurs over an anchor.

You can set the defaultStatus property at any time. You must return true if you want to set the defaultStatus property in the onMouseOut or onMouseOver event handlers.

Examples

In the following example, the statusSetter function sets both the status and defaultStatus properties in an onMouseOver event handler:

function statusSetter() {
   window.defaultStatus = "Click the link for the Netscape home page"
   window.status = "Netscape home page"
}

<A HREF="http://home.netscape.com"
   onMouseOver = "statusSetter(); return true">Netscape</A>

In the previous example, notice that the onMouseOver event handler returns a value of true. You must return true to set status or defaultStatus in an event handler.

See also

status property


defaultValue

Property. A string indicating the default value of a Password, Text, or Textarea object.

Syntax

1. passwordName.defaultValue
2. textName.defaultValue
3. textareaName.defaultValue

Parameters

passwordName is either the value of the NAME attribute of a Password object or an element in the elements array.

textName is either the value of the NAME attribute of a Text object or an element in the elements array.

textareaName is either the value of the NAME attribute of a Textarea object or an element in the elements array.

Property of

Password object, Text object, Textarea object

Implemented in

Navigator 2.0

Tainted?

Yes

Description

The initial value of defaultValue differs for each object:

Setting defaultValue programmatically overrides the initial setting. If you programmatically set defaultValue for the Password object and then evaluate it, JavaScript returns the current value.

You can set the defaultValue property at any time. The display of the related object does not update when you set the defaultValue property, only when you set the value property.

Examples

The following function evaluates the defaultValue property of objects on the surfCity form and displays the values in the msgWindow window:

function defaultGetter() {
   msgWindow=window.open("")
   msgWindow.document.write("hidden.defaultValue is " +
      document.surfCity.hiddenObj.defaultValue + "<BR>")
   msgWindow.document.write("password.defaultValue is " +
      document.surfCity.passwordObj.defaultValue + "<BR>")
   msgWindow.document.write("text.defaultValue is " +
      document.surfCity.textObj.defaultValue + "<BR>")
   msgWindow.document.write("textarea.defaultValue is " +
      document.surfCity.textareaObj.defaultValue + "<BR>")
   msgWindow.document.close()
}

See also

value property


description

Property. A description of a MIME type or plug-in.

Syntax

1. navigator.mimeTypes[index1].description
2. navigator.plugins[index2].description

Parameters

index1 is either an integer representing a MIME type supported by the client or a string containing the type of a MimeType object (from the type property).

index2 is either an integer representing a plug-in installed on the client or a string containing the name of a Plugin object (from the name property).

Property of

Implemented in

Navigator 3.0

Tainted?

No

Description

For MimeType objects, the description property is a description of the content and encoding for the MIME data type.

For Plugin objects, the description property is a description of the plug-in. The description is supplied by the plug-in itself.

description is a read-only property.

Examples

See the examples for the MimeType and Plugin objects.

See also

For MimeType objects: enabledPlugin, type, suffixes properties

For Plugin objects: filename, length, name properties


document

Object. Contains information on the current document, and provides methods for displaying HTML output to the user.

HTML syntax

To define a document object, use standard HTML syntax with the addition of JavaScript event handlers:

<BODY
   BACKGROUND="backgroundImage"
   BGCOLOR="backgroundColor"
   TEXT="foregroundColor"
   LINK="unfollowedLinkColor"
   ALINK="activatedLinkColor"
   VLINK="followedLinkColor"
   [onBlur="handlerText"]
   [onFocus="handlerText"]
   [onLoad="handlerText"]
   [onUnload="handlerText"]>
</BODY>

HTML attributes

BACKGROUND specifies an image that fills the background of the document.

BGCOLOR, TEXT, LINK, ALINK, and VLINK are color specifications expressed as a hexadecimal RGB triplet (in the format "rrggbb" or "#rrggbb") or as one of the string literals listed in "Color values".

Syntax

To use a document object's properties and methods:

1. document.propertyName
2. document.methodName(parameters)

Parameters

propertyName is one of the properties listed below.

methodName is one of the methods listed below.

Property of

window object

Implemented in

Description

An HTML document consists of <HEAD> and <BODY> tags. The <HEAD> tag includes information on the document's title and base (the absolute URL base to be used for relative URL links in the document). The <BODY> tag encloses the body of a document, which is defined by the current URL. The entire body of the document (all other HTML elements for the document) goes within the <BODY> tag.

You can load a new document by using the window.location object.

You can clear the document pane (and remove the text, form elements, and so on so they do not redisplay) by using document.close(); document.open(); document.write(). You can omit the document.open() call if you are writing text or HTML, since write does an implicit open of that mime type if the document stream is closed.

You can reference the anchors, forms, and links of a document by using the anchors, forms, and links arrays. These arrays contain an entry for each anchor, form, or link in a document.

Do not use location as a property of the document object; use the document.URL property instead. The document.location property, which is a synonym for document.URL, will be removed in a future release.

Properties

The document object has the following properties:

Property Description
alinkColor Reflects the ALINK attribute
anchors An array reflecting all the anchors in a document
applets An array reflecting all the applets in a document
bgColor Reflects the BGCOLOR attribute
cookie Specifies a cookie
domain Specifies the domain name of the server that served a document
embeds array An array reflecting all the plugins in a document
fgColor Reflects the TEXT attribute
forms An array reflecting all the forms in a document
images An array reflecting all the images in a document
lastModified Reflects the date a document was last modified
linkColor Reflects the LINK attribute
links An array reflecting all the links in a document
referrer Reflects the URL of the calling document
title Reflects the contents of the <TITLE> tag
URL Reflects the complete URL of a document
vlinkColor Reflects the VLINK attribute

The following objects are also properties of the document object:

Anchor object

Applet

Area (see Link object)

Form object

Image

Link object

Methods

The document object has the following methods:

close (document object)

eval

open (document object)

toString

valueOf

write

writeln

Event handlers

None. The onBlur, onFocus, onLoad, and onUnload event handlers are specified in the <BODY> tag but are actually event handlers for the window object.

Examples

The following example creates two frames, each with one document. The document in the first frame contains links to anchors in the document of the second frame. Each document defines its colors.

doc0.html, which defines the frames, contains the following code:

<HTML>
<HEAD>
<TITLE>Document object example</TITLE>
</HEAD>
<FRAMESET COLS="30%,70%">
<FRAME SRC="doc1.html" NAME="frame1">
<FRAME SRC="doc2.html" NAME="frame2">
</FRAMESET>
</HTML>

doc1.html, which defines the content for the first frame, contains the following code:

<HTML>
<SCRIPT>
</SCRIPT>
<BODY
   BGCOLOR="antiquewhite"
   TEXT="darkviolet"
   LINK="fuchsia"
   ALINK="forestgreen"
   VLINK="navy">
<P><B>Some links</B>
<LI><A HREF="doc2.html#numbers" TARGET="frame2">Numbers</A>
<LI><A HREF="doc2.html#colors" TARGET="frame2">Colors</A>
<LI><A HREF="doc2.html#musicTypes" TARGET="frame2">Music types</A>
<LI><A HREF="doc2.html#countries" TARGET="frame2">Countries</A>
</BODY>
</HTML>

doc2.html, which defines the content for the second frame, contains the following code:

<HTML>
<SCRIPT>
</SCRIPT>
<BODY
   BGCOLOR="oldlace" onLoad="alert('Hello, World.')"
   TEXT="navy">
<P><A NAME="numbers"><B>Some numbers</B></A>
<UL><LI>one
<LI>two
<LI>three
<LI>four</UL>
<P><A NAME="colors"><B>Some colors</B></A>
<UL><LI>red
<LI>orange
<LI>yellow
<LI>green</UL>
<P><A NAME="musicTypes"><B>Some music types</B></A>
<UL><LI>R&B
<LI>Jazz
<LI>Soul
<LI>Reggae</UL>
<P><A NAME="countries"><B>Some countries</B></A>
<UL><LI>Afghanistan
<LI>Brazil
<LI>Canada
<LI>Finland</UL>
</BODY>
</HTML>

See also

Frame object, window object


domain

Property. Specifies the domain name of the server that served a document.

Syntax

document.domain

Property of

document

Tainted?

Yes

Implemented in

Navigator 3.0

Description

The domain property lets scripts on multiple servers share properties when data tainting is not enabled. With tainting disabled, a script running in one window can read properties of another window only if both windows come from the same Web server. But large Web sites with multiple servers might need to share properties among servers. For example, a script on the host www.yahoo.com might need to share properties with a script on the host search.yahoo.com.

If scripts on two different servers change their domain property so that both scripts have the same domain name, both scripts can share properties. For example, a script loaded from search.yahoo.com could set its domain property to "yahoo.com". A script from www.yahoo.com running in another window could also set its domain property to "yahoo.com". Then, since both scripts have the domain "yahoo.com", these two scripts can share properties, even though they did not originate from the same server.

You can change domain only in a restricted way. Initially, domain contains the hostname of the Web server from which the document was loaded. You can set domain only to a domain suffix of itself. For example, a script from search.yahoo.com can't set its domain property to "search.yahoo". And a script from IWantYourMoney.com cannot set its domain to "yahoo.com".

Once you change the domain property, you cannot change it back to its original value. For example, if you change domain from "search.yahoo.com" to "yahoo.com", you cannot reset it to "search.yahoo.com".

You can change domain at any time.

Examples

The following statement changes the domain property to "braveNewWorld.com". This statement is valid only if "braveNewWorld.com" is a suffix of the current domain, such as "www.braveNewWorld.com".

document.domain="braveNewWorld.com"

See also

taint, untaint functions; "Using data tainting for security"


E

Property. Euler's constant and the base of natural logarithms, approximately 2.718.

Syntax

Math.E

Property of

Math

Implemented in

Navigator 2.0

Tainted?

No

Description

Because E is a constant, it is a read-only property of Math.

Examples

The following function returns Euler's constant:

function getEuler() {
   return Math.E
}

See also

exp, LN2, LN10, LOG2E, LOG10E, PI, SQRT1_2, SQRT2 properties


elements array

Property. An array of objects corresponding to form elements (such as checkbox, radio, and Text objects) in source order.

Syntax

1. formName.elements[index]
2. formName.elements.length

Parameters

formName is either the name of a form or an element in the forms array.

index is an integer representing an object on a form or the name of an object as specified by the NAME attribute.

Property of

Form object

Implemented in

Navigator 2.0

Tainted?

No

Description

You can reference a form's elements in your code by using the elements array. This array contains an entry for each object (Button, Checkbox, FileUpload, Hidden, Password, Radio, Reset, Select, Submit, Text, or Textarea object) in a form in source order. For example, if a form has a text field and two checkboxes, these elements are reflected as formName.elements[0], formName.elements[1], and formName.elements[2].

Although you can also reference a form's elements by using the element's name (from the NAME attribute), the elements array provides a way to reference Form objects programmatically without using their names. For example, if the first object on the userInfo form is the userName Text object, you can evaluate it in either of the following ways:

userInfo.userName.value
userInfo.elements[0].value

To obtain the number of elements on a form, use the length property: formName.elements.length. Each radio button in a Radio object appears as a separate element in the elements array.

Elements in the elements array are read-only. For example, the statement formName.elements[0]="music" has no effect.

The value of each element in the elements array is the full HTML statement for the object.

Properties

The elements array has the following properties:

Property Description
length Reflects the number of elements in the form

Examples

See the examples for the Frame property.

See also

Form object


elements property

Property. An array of objects corresponding to form elements (such as Checkbox, Radio, and Text objects) in source order. See the elements array for information.


embeds array

Property. An array reflecting all the <EMBED> tags in a document in source order.

HTML syntax

To generate output from a plug-in application, use standard HTML syntax:

<EMBED
   SRC=source
   NAME=embedName
   HEIGHT=height
   WIDTH=width>
   
[parameterName=parameterValue]
   [ ... parameterName=parameterValue]
</EMBED>

For the complete syntax of the <EMBED> tag, see http://home.netscape.com/eng/mozilla/3.0/handbook/plugins/index.html.

HTML attributes

SRC=source</I> specifies the URL containing the source content.

NAME=embedName specifies the name of the embedded object in the document. You can use this name when indexing the embeds array.

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.

parameterName=parameterValue specifies the name and value of a parameter to pass to the embedded object's plug-in.

Property of

document

Implemented in

Navigator 3.0

Tainted?

No

Description

You can reference embedded objects (created with the <EMBED> tag) in your code by using the embeds array. This array contains an entry for each <EMBED> tag in a document in source order. For example, if a document contains three <EMBED> tags, these <EMBED> tags are reflected as document.embeds[0], document.embeds[1], and document.embeds[2].

Elements in the embeds array may have public callable functions, if they reference a "LiveConnected" plug-in. See Chapter 4, "LiveConnect."

To use the embeds array:

1. document.embeds[index]
2. document.embeds.length

index is an integer representing an <EMBED> tag or the name of an embedded object as specified by the NAME attribute.

To obtain the number of <EMBED> tags in a document, use the length property: document.embeds.length.

Use the elements in the embeds array to interact with the plug-in that is displaying the embedded object. If a plug-in is not Java-enabled, you cannot do anything with its element in the embeds array. The fields and methods of the elements in the embeds array vary from plug-in to plug-in; see the documentation supplied by the plug-in manufacturer.

When you use the <EMBED> tag to generate output from a plug-in application, you are not creating a Plugin object. See the Plugin object.

Elements in the embeds array are read-only. For example, the statement document.embeds[0]="myavi.avi" has no effect.

Properties

The embeds array has the following properties:

Property Description
length Reflects the number of elements in the array

Methods

Event handlers

None.

Examples

The following code includes an audio plug-in in a document.

<EMBED SRC="train.au" HEIGHT=50 WIDTH=250>

See also

Plugin object


enabledPlugin

Property. The Plugin object for the plug-in that is configured for the specified MIME type.

Syntax

navigator.mimeTypes[index].enabledPlugin

Parameters

index is either an integer representing a MIME type supported by the client or a string containing the type of a MimeType object (from the type property).

Property of

MimeType

Implemented in

Navigator 3.0

Tainted?

No

Description

Use the enabledPlugin property to determine which plug-in is configured for a specific MIME type. Each plug-in may support multiple MIME types, and each MIME type could potentially be supported by multiple plug-ins. However, only one plug-in can be configured for a MIME type. (On Macintosh and Unix, the user can configure the handler for each MIME type; on Windows, the handler is determined at Navigator start-up time.)

The enabledPlugin property is a reference to a Plugin object that represents the plug-in that is configured for the specified MIME type. If the MIME type does not have a plug-in configured, enabledPlugin is null.

Without the enabledPlugin property, you could determine if the user has a particular plug-in installed, if their Navigator can handle a particular MIME type, and if the MIME type is supported by any plug-ins. But you could not determine whether a plug-in is configured for the MIME type. You might need to know this information, for example, so you could dynamically emit an <EMBED> tag on the page if the user has a plug-in configured for the MIME type.

enabledPlugin is a read-only property.

Examples

The following example determines whether the Shockwave plug-in is installed. If it is, a movie is displayed.

// Can we display Shockwave movies?
mimetype = navigator.mimeTypes["application/x-director"]
if (mimetype) {
   // Yes, so can we display with a plug-in?
   plugin = mimetype.enabledPlugin
   if (plugin)
      // Yes, so show the data in-line
      document.writeln("Here\'s a movie: <EMBED SRC=mymovie.dir HEIGHT=100 WIDTH=100>")
      else
      // No, so provide a link to the data
      document.writeln("<A HREF='mymovie.dir>Click here</A> to see a movie.")
   } else {
   // No, so tell them so
   document.writeln("Sorry, can't show you this cool movie.")
}

See also the examples for the MimeType object.

See also

description, type, suffixes properties


encoding

Property. A string specifying the MIME encoding of the form.

Syntax

formName.encoding

Parameters

formName is either the name of a form or an element in the forms array.

Property of

Form object

Implemented in

Navigator 2.0

Tainted?

No

Description

The encoding property initially reflects the ENCTYPE attribute of the <FORM> tag; however, setting encoding overrides the ENCTYPE attribute.

You can set the encoding property at any time.

Examples

The following function returns the value of the musicForm encoding property:

function getEncoding() {
   return document.musicForm.encoding
}

See also

action, method, target properties; Form object


escape

Function. Returns the ASCII encoding of an argument in the ISO Latin-1 character set.

Syntax

escape("string")

Parameters

string is a nonalphanumeric string in the ISO Latin-1 character set, or a property of an existing object.

Implemented in

Navigator 2.0

Description

The value returned by the escape function is a string of the form "%xx," where xx is the ASCII encoding of a character in the argument. If you pass the escape function an alphanumeric character, the escape function returns the same character. escape is a top-level function not associated with any object.

Examples

The following example returns "Hello%2C%20World":

escape("Hello, World")

The following example returns "%26":

escape("&")

The following example returns "%21%23":

escape("!#")

See also

unescape function


eval

Method. The eval method evaluates a string of JavaScript code in the context of the specified object.

Syntax

[objectName.]eval(string)

Parameters

objectName is the object for which a string is to be evaluated. If omitted, the string is evaluated without regard to any object.

string is any string representing a JavaScript expression, statement, or sequence of statements. The expression can include variables and properties of existing objects.

Method of

eval is a method of all objects.

Implemented in

Navigator 2.0: a built-in JavaScript function, not associated with any object, but part of the language itself

Navigator 3.0: a method of every object

Description

The argument of the eval method is a string. If the string represents an expression, eval evaluates the expression. If the argument represents one or more JavaScript statements, eval performs the statements. Do not call eval to evaluate an arithmetic expression; JavaScript evaluates arithmetic expressions automatically.

If you construct an arithmetic expression as a string, you can use eval to evaluate it at a later time. For example, suppose you have a variable x. You can postpone evaluation of an expression involving x by assigning the string value of the expression, say "3 * x + 2", to a variable, and then calling eval at a later point in your script.

Examples

Example 1. Both of the write statements below display 42. The first evaluates the string "x + y + 1," and the second evaluates the string "42."

var x = 2
var y = 39
var z = "42"
document.write(eval("x + y + 1"), "<BR>")
document.write(eval(z), "<BR>")

Example 2. In the following example, the getFieldName(n) function returns the name of the nth form element as a string. The first statement assigns the string value of the third form element to the variable field. The second statement uses eval to display the value of the form element.

var field = getFieldName(3) 
document.write("The field named ", field, " has value of ", eval(field + ".value"))

Example 3. The following example uses eval to evaluate the string str. This string consists of JavaScript statements that open an Alert dialog box and assigns z a value of 42 if x is five, and assigns zero to z otherwise. When the second statement is executed, eval will cause these statements to be performed, and it will also evaluate the set of statements and return the value that is assigned to z.

var str = "if (x == 5) {alert('z is 42'); z = 42;} else z = 0; "
document.write("<P>z is ", eval(str))

Example 4. In the following example, the setValue function uses eval to assign the value of the variable newValue to the text field textObject:

function setValue (textObject, newValue) {
   eval ("document.forms[0]." + textObject + ".value") = newValue
}

Example 5. The following example creates breed as a property of the object myDog, and also as a variable. The first write statement uses eval('breed') without specifying an object; the string "breed" is evaluated without regard to any object, and the write method displays "Shepherd", which is the value of the breed variable. The second write statement uses myDog.eval('breed') which specifies the object myDog; the string "breed" is evaluated with regard to the myDog object, and the write method displays "Lab", which is the value of the breed property of the myDog object.

function Dog(name,breed,color) {
   this.name=name
   this.breed=breed
   this.color=color
}
myDog = new Dog("Gabby")
myDog.breed="Lab"
var breed='Shepherd'
document.write("<P>" + eval('breed'))
document.write("<BR>" + myDog.eval('breed'))

Example 6. The following example uses eval within a function that defines an object type, flintstone. The statement fred = new flintstone("x=42") creates the object fred with the properties x, y, z, and z2. The write statements display the values of these properties as 42, 43, 44, and 45, respectively.

function flintstone(str) {
   this.eval("this."+str)
   this.eval("this.y=43")
   this.z=44
   this["z2"] = 45
}
fred = new flintstone("x=42")
document.write("<BR>fred.x is " + fred.x)
document.write("<BR>fred.y is " + fred.y)
document.write("<BR>fred.z is " + fred.z)
document.write("<BR>fred.z2 is " + fred.z2)


exp

Method. Returns enumber, where number is the argument, and e is Euler's constant, the base of the natural logarithms.

Syntax

Math.exp(number)

Parameters

number is any numeric expression or a property of an existing object.

Method of

Math

Implemented in

Navigator 2.0

Examples

The following function returns the exp value of the variable x:

function getExp(x) {
   return Math.exp(x)
}

If you pass getExp the value 1, it returns 2.718281828459045.

See also

E, log, pow methods


[Next reference file]
file: /Techref/language/JAVA/SCRIPT/ref_d-e.htm, 67KB, , updated: 2009/2/2 13:27, local time: 2024/11/22 18:59,
TOP NEW HELP FIND: 
3.144.46.90: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?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://sxlist.com/techref/language/JAVA/SCRIPT/ref_d-e.htm"> Date </A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to sxlist.com!


Site supported by
sales, advertizing,
& kind contributors
just like you!

Please don't rip/copy
(here's why

Copies of the site on CD
are available at minimal cost.
 

Welcome to sxlist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .