-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathref_d-e.html
632 lines (499 loc) · 27.2 KB
/
ref_d-e.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
<html>
<body>
<a name="Date_object"><h2>Date object</h2></a>
<p>Lets you work with dates and times.
<h3>Syntax</h3>
<p>To create a Date object:
<pre>
1. <i>dateObjectName</i> = new Date()
2. <i>dateObjectName</i> = new Date("<i>month day</i>, <i>year hours</i>:<i>minutes</i>:<i>seconds</i>")
3. <i>dateObjectName</i> = new Date(<i>year</i>, <i>month</i>, <i>day</i>)
4. <i>dateObjectName</i> = new Date(<i>year</i>, <i>month</i>, <i>day</i>, <i>hours</i>, <i>minutes</i>, <i>seconds</i>)
</pre>
<i>dateObjectName</i> is either the name of a new object or a property of an existing object.
<br><i>month, day, year, hours, minutes, and seconds</i> are string values for form 2 of the syntax. For forms 3 and 4, they are integer values.
<p>To use Date methods:
<pre>
<i>dateObjectName.methodName(parameters)</i>
</pre>
<i>dateObjectName</i> is either the name of an existing Date object or a property of an existing object..
<br><i>methodName</i> is one of the methods listed below.
<p>Exceptions: The Date object's parse and UTC methods are static methods that you use as follows:
<pre>
Date.UTC(<i>parameters</i>)
Date.parse(<i>parameters</i>)
</pre>
<h3>Property of</h3>
<li>None.
<h3>Description</h3>
<p>The Date object is a built-in JavaScript object.
<p>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.
<p>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.
<h3>Properties</h3>
<li>None.
<h3>Methods</h3>
<li><a href="ref_f-g.html#getDate_method">getDate</a>
<li><a href="ref_f-g.html#getDay_method">getDay</a>
<li><a href="ref_f-g.html#getHours_method">getHours</a>
<li><a href="ref_f-g.html#getMinutes_method">getMinutes</a>
<li><a href="ref_f-g.html#getMonth_method">getMonth</a>
<li><a href="ref_f-g.html#getSeconds_method">getSeconds</a>
<li><a href="ref_f-g.html#getTime_method">getTime</a>
<li><a href="ref_f-g.html#getTimezoneOffset_method">getTimezoneOffset</a>
<li><a href="ref_f-g.html#getYear_method">getYear</a>
<li><a href="ref_m-q.html#parse_method">parse</a>
<li><a href="ref_s-s.html#setDate_method">setDate</a>
<li><a href="ref_s-s.html#setHours_method">setHours</a>
<li><a href="ref_s-s.html#setMinutes_method">setMinutes</a>
<li><a href="ref_s-s.html#setMonth_method">setMonth</a>
<li><a href="ref_s-s.html#setSeconds_method">setSeconds</a>
<li><a href="ref_s-s.html#setTime_method">setTime</a>
<li><a href="ref_s-s.html#setYear_method">setYear</a>
<li><a href="ref_t-z.html#toGMTString_method">toGMTString</a>
<li><a href="ref_t-z.html#toLocaleString_method">toLocaleString</a>
<li><a href="ref_t-z.html#UTC_method">UTC</a>
<h3>Event handlers</h3>
<li>None. Built-in objects do not have event handlers.
<h3>Examples</h3>
<p>
<xmp>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)
</xmp>
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="defaultChecked_property"><h2>defaultChecked property</h2></a>
<p>
A Boolean value indicating the default selection state of a checkbox or radio button.
<h3>Syntax</h3>
<pre>
1. <i>checkboxName</i>.defaultChecked
2. <i>radioName</i>[<i>index</i>].defaultChecked
</pre>
<p><i>checkboxName</i> is either the value of the NAME attribute of a checkbox object or an element in the <i>elements</i> array.
<br><i>radioName</i> is the value of the NAME attribute of a radio object.
<br><i>index</i> is an integer representing a radio button in a radio object.
<h3>Property of</h3>
<p><a href="ref_a-c.html#checkbox_object">checkbox</a>, <a href="ref_r-r.html#radio_object">radio</a>
<h3>Description</h3>
<p>If an 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.
<p>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.
<h3>Examples</h3>
<p>The following example resets an array of radio buttons called <i>musicType</i> on the <i>musicForm</i> form to the default selection state.
<pre>
function radioResetter() {
var i=""
for (i in document.musicForm.musicType) {
if (document.musicForm.musicType[i].defaultChecked==true) {
document.musicForm.musicType[i].checked=true
}
}
}
</pre>
<h3>See also</h3>
<li><a href="ref_a-c.html#checked_property">checked</a> property
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="defaultSelected_property"><h2>defaultSelected property</h2></a>
<p>
A Boolean value indicating the default selection state of an option in a select object.
<h3>Syntax</h3>
<pre><i>selectName</i>.options[<i>index</i>].defaultSelected</pre>
<p><i>selectName</i> is either the value of the NAME attribute of a select object or an element in the <i>elements</i> array.
<br><i>index</i> is an integer representing an option in a select object.
<h3>Property of</h3>
<p><a href="ref_s-s.html#select_object">options</a> array
<h3>Description</h3>
<p>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.
<p>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.
<p>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.
<h3>Examples</h3>
<p>In the following example, the <i>restoreDefault()</i> function returns the <i>musicType</i> select object to its default state. The <b>for</b> loop uses the options array to evaluate every option in the select object. The <b>if</b> statement sets the selected property if defaultSelected is true.
<pre>
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
}
}
}
</pre>
The previous example assumes that the select object is similar to the following:
<pre>
<SELECT; NAME="musicType">
<OPTION; SELECTED> R&B;
<OPTION;> Jazz
<OPTION;> Blues
<OPTION;> New Age
</SELECT>
</pre>
<h3>See also</h3>
<li><a href="ref_h-l.html#index_property">index</a>, <a href="ref_s-s.html#selected_property">selected</a>, <a href="ref_s-s.html#selectedIndex_property">selectedIndex</a> properties
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="defaultStatus_property"><h2>defaultStatus property</h2></a>
<p>
The default message displayed in the status bar at the bottom of the window.
<h3>Syntax</h3>
<pre><i>windowReference</i>.defaultStatus</pre>
<p><i>windowReference</i> is a valid way of referring to a window, as described in the <a href="ref_t-z.html#window_object">window</a> object.
<h3>Property of</h3>
<p><a href="ref_t-z.html#window_object">window</a>
<h3>Description</h3>
<p>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.
<p>You can set the defaultStatus property at any time. You must return true if you want to set the defaultStatus property in the onMouseOver event handler.
<h3>Examples</h3>
<p>In the following example, the <i>statusSetter()</i> function sets both the status and defaultStatus properties in an onMouseOver event handler:
<pre>
function statusSetter() {
window.defaultStatus = "Click the link for the Netscape home page"
window.status = "Netscape home page"
}
<A; HREF="http://www.netscape.com"
onMouseOver = "statusSetter(); return true">Netscape;</A>
</pre>
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.
<h3>See also</h3>
<li><a href="ref_s-s.html#status_property">status</a> property
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="defaultValue_property"><h2>defaultValue property</h2></a>
<p>
A string indicating the default value of a password, text, or textarea object.
<h3>Syntax</h3>
<pre>
1. <i>passwordName</i>.defaultValue
2. <i>textName</i>.defaultValue
3. <i>textareaName</i>.defaultValue
</pre>
<p><i>passwordName</i> is either the value of the NAME attribute of a password object or an element in the <i>elements</i> array.
<br><i>textName</i> is either the value of the NAME attribute of a text object or an element in the <i>elements</i> array.
<br><i>textareaName</i> is either the value of the NAME attribute of a textarea object or an element in the <i>elements</i> array.
<h3>Property of</h3>
<p><a href="ref_m-q.html#password_object">password</a>, <a href="ref_t-z.html#text_object">text</a>, <a href="ref_t-z.html#textarea_object">textarea</a>
<h3>Description</h3>
<p>The initial value of defaultValue differs for each object:
<li>For text objects, it initially reflects the value of the VALUE attribute.
<li>For textarea objects, it initially reflects the value specified between the <TEXTAREA;> and </TEXTAREA> tags.
<li>For password objects, it initially is null (for security reasons), regardless of the value of the VALUE attribute.
<p>Setting defaultValue programatically overrides the initial setting. If you programatically set defaultValue for the password object and then evaluate it, JavaScript returns the current value.
<p>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.
<h3>Examples</h3>
<p>The following function evaluates the defaultValue property of objects on the <i>surfCity</i> form and displays the values in the <i>msgWindow</i> window:
<pre>
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()
}
</pre>
<h3>See also</h3>
<li><a href="ref_t-z.html#value_property">value</a> property
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="document_object"><h2>document object</h2> </a>
<p>Contains information on the current document, and provides methods for displaying HTML output to the user.
<h3>Syntax</h3>
<p>To define a document object, use standard HTML syntax:
<pre>
<BODY;
BACKGROUND="<i>backgroundImage</i>"
BGCOLOR="<i>backgroundColor</i>"
TEXT="<i>foregroundColor</i>"
LINK="<i>unfollowedLinkColor</i>"
ALINK="<i>activatedLinkColor</i>"
VLINK="<i>followedLinkColor</i>"
[onLoad="<i>handlerText</i>"]
[onUnload="<i>handlerText</i>"]>
</BODY>
</pre>
<i>BACKGROUND</i> specifies an image that fills the background of the document.
<br><i>BGCOLOR</i>, <i>TEXT</i>, <i>LINK</i>, <i>ALINK</i>, and <i>VLINK</i> are color specifications expressed as a hexadecimal RGB triplet (in the format "rrggbb" or "#rrggbb") or as one of the string literals listed in <a href="colors.html">Color Values</a>.
<p>To use a document object's properties and methods:
<pre>
1. document.<i>propertyName</i>
2. document.<i>methodName</i>(<i>parameters</i>)
</pre>
<i>propertyName</i> is one of the properties listed below.
<br><i>methodName</i> is one of the methods listed below.
<h3>Property of</h3>
<li><a href="ref_t-z.html#window_object">window</a>
<h3>Description</h3>
<p>An HTML document consists of a <HEAD;> and <BODY;> tag. The <HEAD;> 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.
<p>You can load a new document by using the <a href="ref_h-l.html#location_object">location</a> object.
<p>You can reference the anchors, forms, and links of a document by using the <i>anchors, forms,</i> and <i>links</i> arrays. These arrays contain an entry for each anchor, form, or link in a document.
<h3>Properties</h3>
<li><a href="ref_a-c.html#alinkColor_property">alinkColor</a> reflects the ALINK attribute
<li><a href="ref_a-c.html#anchor_object">anchors</a> is an array reflecting all the anchors in a document
<li><a href="ref_a-c.html#bgColor_property">bgColor</a> reflects the BGCOLOR attribute
<li><a href="ref_a-c.html#cookie_property">cookie</a> specifies a cookie
<li><a href="ref_f-g.html#fgColor_property">fgColor</a> reflects the TEXT attribute
<li><a href="ref_f-g.html#form_object">forms</a> is an array reflecting all the forms in a document
<li><a href="ref_h-l.html#lastModified_property">lastModified</a> reflects the date a document was last modified
<li><a href="ref_h-l.html#linkColor_property">linkColor</a> reflects the LINK attribute
<li><a href="ref_h-l.html#link_object">links</a> is an array reflecting all the links in a document
<li><a href="ref_h-l.html#location_property">location</a> reflects the complete URL of a document
<li><a href="ref_r-r.html#referrer_property">referrer</a> reflects the URL of the calling document
<li><a href="ref_t-z.html#title_property">title</a> reflects the contents of the <TITLE;> tag
<li><a href="ref_t-z.html#vlinkColor_property">vlinkColor</a> reflects the VLINK attribute
<p>The following objects are also properties of the document object:
<li><a href="ref_a-c.html#anchor_object">anchor</a>
<li><a href="ref_f-g.html#form_object">form</a>
<li><a href="ref_h-l.html#history_object">history</a>
<li><a href="ref_h-l.html#link_object">link</a>
<h3>Methods</h3>
<li><a href="ref_a-c.html#clear_method">clear</a>
<li><a href="ref_a-c.html#close_document_method">close</a>
<li><a href="ref_m-q.html#open_document_method">open</a>
<li><a href="ref_t-z.html#write_method">write</a>
<li><a href="ref_t-z.html#writeln_method">writeln</a>
<h3>Event handlers</h3>
<li>None. The onLoad and onUnload event handlers are specified in the <BODY;> tag but are actually event handlers for the window object.
<h3>Examples</h3>
<p>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.
<p>DOC0.HTML, which defines the frames, contains the following code:
<xmp>
<html>
<head>
<title>Document object example</title>
</head>
<frameset cols="30%,70%">
<frame src="/web/19970617232643fw_/http://home.netscape.com:80/eng/mozilla/2.0/handbook/javascript/doc1.html" name="frame1">
<frame src="/web/19970617232643fw_/http://home.netscape.com:80/eng/mozilla/2.0/handbook/javascript/doc2.html" name="frame2">
</frameset>
</html>
</xmp>
<p>DOC1.HTML, which defines the content for the first frame, contains the following code:
<xmp>
<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>
</xmp>
<p>DOC2.HTML, which defines the content for the second frame, contains the following code:
<xmp>
<html>
<script>
</script>
<body bgcolor="oldlace" onload="alert('Hello, World.')" text="navy">
<p><a name="numbers"><b>Some numbers</b></a>
<li>one
<li>two
<li>three
<li>four
<li>five
<li>six
<li>seven
<li>eight
<li>nine
<p><a name="colors"><b>Some colors</b></a>
<li>red
<li>orange
<li>yellow
<li>green
<li>blue
<li>purple
<li>brown
<li>black
<p><a name="musicTypes"><b>Some music types</b></a>
<li>R&B;
<li>Jazz
<li>Soul
<li>Reggae
<li>Rock
<li>Country
<li>Classical
<li>Opera
<p><a name="countries"><b>Some countries</b></a>
<li>Afghanistan
<li>Brazil
<li>Canada
<li>Finland
<li>India
<li>Italy
<li>Japan
<li>Kenya
<li>Mexico
<li>Nigeria
</body>
</html>
</xmp>
<h3>See also</h3>
<li><a href="ref_f-g.html#frame_object">frame</a> and <a href="ref_t-z.html#window_object">window</a> objects
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="E_property"><h2>E property</h2></a>
<p>
Euler's constant and the base of natural logarithms, approximately 2.718.
<h3>Syntax</h3>
<pre>Math.E</pre>
<h3>Property of</h3>
<p><a href="ref_m-q.html#Math_object">Math</a>
<h3>Description</h3>
<p>Because E is a constant, it is a read-only property of Math.
<h3>Examples</h3>
<p>The following example displays Euler's constant:
<pre>document.write("Euler's constant is " + Math.E)</pre>
<h3>See also</h3>
<li><a href="ref_h-l.html#LN2_property">LN2</a>, <a href="ref_h-l.html#LN10_property">LN10</a>, <a href="ref_h-l.html#LOG2E_property">LOG2E</a>, <a href="ref_h-l.html#LOG10E_property">LOG10E</a>, <a href="ref_m-q.html#PI_property">PI</a>, <a href="ref_s-s.html#SQRT1_2_property">SQRT1_2</a>, <a href="ref_s-s.html#SQRT2_property">SQRT2</a> properties
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="elements_object"><h2><i>elements</i> array</h2> </a>
<p>An array of objects corresponding to form elements (such as checkbox, radio, and text objects) in source order.
<h3>Syntax</h3>
<pre>
1. <i>formName</i>.elements[<i>index</i>]
2. <i>formName</i>.elements.length
</pre>
<p><i>formName</i> is either the name of a form or an element in the <i>forms</i> array.
<br><i>index</i> is an integer representing an object on a form.
<h3>Property of</h3>
<li><a href="ref_f-g.html#form_object">form</a>
<h3>Description</h3>
<p>You can reference a form's elements in your code by using the <i>elements</i> array. This array contains an entry for each object (button, checkbox, 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 <tt><i>formName</i>.elements[0]</tt>, <tt><i>formName</i>.elements[1]</tt>, and <tt><i>formName</i>.elements[2]</tt>.
<p>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 programatically without using their names. For example, if the first object on the <i>userInfo</i> form is the <i>userName</i> text object, you can evaluate it in either of the following ways:
<pre>
userInfo.userName.value
userInfo.elements[0].value
</pre>
<p>To obtain the number of elements on a form, use the length property: <tt><i>formName</i>.elements.length</tt>. Each radio button in a radio object appears as a separate element in the <i>elements</i> array.
<p>Elements in the <i>elements</i> array are read-only. For example, the statement <tt><i>formName</i>.elements[0]="music"</tt> has no effect.
<p>The value of each element in the <i>elements</i> array is the full HTML statement for the object.
<h3>Properties</h3>
<li><a href="ref_h-l.html#length_property">length</a> reflects the number of elements on a form
<h3>Examples</h3>
<p>See the examples for the <a href="ref_m-q.html#name_property">name</a> property.
<h3>See also</h3>
<li><a href="ref_f-g.html#form_object">form</a> object
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="elements_property"><h2>elements property</h2></a>
<p>An array of objects corresponding to form elements (such as checkbox, radio, and text objects) in source order. See <a href="ref_d-e.html#elements_object"><i>elements</i></a> array.
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="encoding_property"><h2>encoding property</h2></a>
<p>
A string specifying the MIME encoding of the form.
<h3>Syntax</h3>
<pre><i>formName</i>.encoding</pre>
<p><i>formName</i> is either the name of a form or an element in the <i>forms</i> array.
<h3>Property of</h3>
<p><a href="ref_f-g.html#form_object">form</a>
<h3>Description</h3>
<p>The encoding property initially reflects the ENCTYPE attribute of the <FORM;> tag; however, setting encoding overrides the ENCTYPE attribute.
<p>You can set the encoding property at any time.
<p>Certain values of the encoding property may require specific values for other form properties. See <a href="https://web.archive.org/web/19970617232643/http://www.ics.uci.edu/pub/ietf/html/rfc1867.txt" target="_top">RFC 1867</a> for more information.
<h3>Examples</h3>
<p>The following function returns the value of the <i>musicForm</i> encoding property:
<pre>
function getEncoding() {
return document.musicForm.encoding
}
</pre>
<h3>See also</h3>
<li><a href="ref_a-c.html#action_property">action</a>, <a href="ref_m-q.html#method_property">method</a>, <a href="ref_t-z.html#target_property">target</a> properties
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="escape_method"><h2>escape function</h2></a>
<p>
Returns the ASCII encoding of an argument in the ISO Latin-1 character set.
<h3>Syntax</h3>
<pre>escape("<i>string</i>")</pre>
<p><i>string</i> is a non-alphanumeric string in the ISO Latin-1 character set, or a property of an existing object.
<h3>Description</h3>
<p>The escape function is not a method associated with any object, but is part of the language itself.
<p>The value returned by the escape function is a string of the form "%xx", where <i>xx</i> 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.
<h3>Examples</h3>
<p>The following example returns "%26"
<pre>
escape("&")
</pre>
<p>The following example returns "%21%23"
<pre>
escape("!#")
</pre>
<h3>See also</h3>
<li><a href="ref_t-z.html#unescape_method">unescape</a> function
<!------------------------------------------------------------------------------------------------>
<hr>
<a name="eval_method"> <h2>eval function</h2></a>
<p>
The eval function evaluates a string and returns a value.
<h3>Syntax</h3>
<pre>eval(<i>string</i>)</pre>
<i>string</i> is any string representing a JavaScript expression, statement, or sequence of statements. The expression can include variables and properties of existing objects.
<h3>Description</h3>
<p>The eval function is a built-in JavaScript function. It is not a method associated with any object, but is part of the language itself.
<p>The argument of the eval function is a string. Do not call eval to evaluate an arithmetic expression. JavaScript evaluates arithmetic expressions automatically. If the argument represents an expression, eval evaluates the expression. If the argument represents one or more JavaScript statements, eval performs the statements.
<p>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 <i>x</i>. You can postpone evaluation of an expression involving <i>x</i> by assigning the string value of the expression, say <tt>"3 * x; + 2;"</tt>, to a variable, and then calling eval at a later point in your script.
<h3>Examples</h3>
<p><b>Example 1.</b> Both of the write statements below display 42. The first evaluates the string "x + y + 1", and the second evaluates the string "42".
<pre>
var x = 2
var y = 39
var z = "42"
document.write(eval("x + y + 1"), "<BR;>")
document.write(eval(z), "<BR;>")
</pre>
<p><b>Example 2.</b> In the following example, the <i>getFieldName(n)</i> 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 <i>field</i>. The second statement uses eval to display the value of the form element.
<pre>
var field = getFieldName(3)
document.write("The field named ", field, " has value of ", eval(field + ".value"))
</pre>
<p><b>Example 3.</b> The following example uses eval to evaluate the string <i>str</i>. This string consists of JavaScript statements that opens 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.
<pre>
var str = "if (x == 5) {alert('z is 42'); z = 42;} else z = 0; "
document.write("<P;>z; is ", eval(str))
</pre>
<p><b>Example 4.</b> In the following example, the <i>setValue()</i> function uses eval to assign the value of the variable <i>newValue</i> to the text field <i>textObject</i>.
<pre>
function setValue (textObject, newValue) {
eval ("document.forms[0]." + textObject + ".value") = newValue
}
</pre>
<!------------------------------------------------------------------------------------------------>
<hr>
<a name="exp_method"><h2>exp method</h2></a>
<p>
Returns e<sup><i>number</i></sup>, where <i>number</i> is the argument, and <i>e</i> is Euler's constant, the base of the natural logarithms.
<h3>Syntax</h3>
<pre>Math.exp(<i>number</i>)</pre>
<i>number</i> is any numeric expression or a property of an existing object.
<h3>Method of</h3>
<p><a href="ref_m-q.html#Math_object">Math</a>
<h3>Examples</h3>
<pre>
//Displays the value 2.718281828459045
document.write("The value of e<SUP;>1;</SUP> is " + Math.exp(1))
</pre>
<h3>See also</h3>
<li><a href="ref_h-l.html#log_method">log</a>, <a href="ref_m-q.html#pow_method">pow</a> methods
<!------------------------------------------------------------------------------------------------>
<hr>
<script>
document.write("<FONT SIZE=-2>Last modified " + document.lastModified)
</script>
<p>
</body>
<html>
<!--
FILE ARCHIVED ON 23:26:43 Jun 17, 1997 AND RETRIEVED FROM THE
INTERNET ARCHIVE ON 18:14:29 Nov 08, 2018.
ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C.
SECTION 108(a)(3)).
-->