-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathref_m-q.html
998 lines (773 loc) · 47.7 KB
/
ref_m-q.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
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
<html>
<body>
<a name="Math_object"><h2>Math object</h2></a>
<p>A built-in object that has properties and methods for mathematical constants and functions. For example, the Math object's PI property has the value of pi.
<h3>Syntax</h3>
<p>To use a Math object:
<pre>
1. Math.<i>propertyName</i>
2. Math.<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>None.
<h3>Description</h3>
<p>The Math object is a built-in JavaScript object.
<p>You reference the constant PI as <tt>Math.PI</tt>. Constants are defined with the full precision of real numbers in JavaScript.
<p>
Similarly, you reference Math functions as methods. For example, the sine function is <tt>Math.sin(<i>argument</i>)</tt>, where <i>argument</i> is the argument.
<p>
It is often convenient to use the <b>with</b> statement when a section of code uses several Math constants and methods, so you don't have to type "Math" repeatedly. For example,
<pre>
with (Math) {
a = PI * r*r
y = r*sin(theta)
x = r*cos(theta)
}
</pre>
<h3>Properties</h3>
<li><a href="ref_d-e.html#E_property">E</a>
<li><a href="ref_h-l.html#LN2_property">LN2</a>
<li><a href="ref_h-l.html#LN10_property">LN10</a>
<li><a href="ref_h-l.html#LOG2E_property">LOG2E</a>
<li><a href="ref_h-l.html#LOG10E_property">LOG10E</a>
<li><a href="ref_m-q.html#PI_property">PI</a>
<li><a href="ref_s-s.html#SQRT1_2_property">SQRT1_2</a>
<li><a href="ref_s-s.html#SQRT2_property">SQRT2</a>
<h3>Methods</h3>
<li><a href="ref_a-c.html#abs_method">abs</a>
<li><a href="ref_a-c.html#acos_method">acos</a>
<li><a href="ref_a-c.html#asin_method">asin</a>
<li><a href="ref_a-c.html#atan_method">atan</a>
<li><a href="ref_a-c.html#ceil_method">ceil</a>
<li><a href="ref_a-c.html#cos_method">cos</a>
<li><a href="ref_d-e.html#exp_method">exp</a>
<li><a href="ref_f-g.html#floor_method">floor</a>
<li><a href="ref_h-l.html#log_method">log</a>
<li><a href="ref_m-q.html#max_method">max</a>
<li><a href="ref_m-q.html#min_method">min</a>
<li><a href="ref_m-q.html#pow_method">pow</a>
<li><a href="ref_r-r.html#random_method">random</a>
<li><a href="ref_r-r.html#round_method">round</a>
<li><a href="ref_s-s.html#sin_method">sin</a>
<li><a href="ref_s-s.html#sqrt_method">sqrt</a>
<li><a href="ref_t-z.html#tan_method">tan</a>
<h3>Event handlers</h3>
<li>None. Built-in objects do not have event handlers.
<h3>Examples</h3>
<p>See the examples for the individual properties and methods.
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="max_method"><h2>max method</h2></a>
<p>
Returns the greater of two numbers.
<h3>Syntax</h3>
<pre>Math.max(<i>number1, number2</i>)</pre>
<i>number1</i> and <i>number2</i> are any numeric arguments or the properties of existing objects.
<h3>Method of</h3>
<p><a href="ref_m-q.html#Math_object">Math</a>
<h3>Examples</h3>
<pre>
//Displays the value 20
document.write("The maximum value is " + Math.max(10,20))
//Displays the value -10
document.write("<P;>The; maximum value is " + Math.max(-10,-20))
</pre>
<h3>See also</h3>
<li><a href="ref_m-q.html#min_method">min</a> method
<!------------------------------------------------------------------------------------------------>
<hr>
<a name="method_property"><h2>method property</h2></a>
<p>
A string specifying how form field input information is sent to the server.
<h3>Syntax</h3>
<pre><i>formName</i>.method</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 method property is a reflection of the METHOD attribute of the <FORM;> tag. The method property should evaluate to either "get" or "post".
<p>You can set the method property at any time.
<p>Certain values of the method property may require specific values for other form properties. See <a href="https://web.archive.org/web/19970617232705/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> method property:
<pre>
function getMethod() {
return document.musicForm.method
}
</pre>
<h3>See also</h3>
<li><a href="ref_a-c.html#action_property">action</a>, <a href="ref_d-e.html#encoding_property">encoding</a>, <a href="ref_t-z.html#target_property">target</a> properties
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="min_method"><h2>min method</h2></a>
<p>
Returns the lesser of two numbers.
<h3>Syntax</h3>
<pre>Math.min(<i>number1, number2</i>)</pre>
<i>number1</i> and <i>number2</i> are any numeric arguments or the properties of existing objects.
<h3>Method of</h3>
<p><a href="ref_m-q.html#Math_object">Math</a>
<h3>Examples</h3>
<pre>
//Displays the value 10
document.write("<p>The minimum value is " + Math.min(10,20))
//Displays the value -20
document.write("<P;>The; minimum value is " + Math.min(-10,-20))
</pre>
<h3>See also</h3>
<li><a href="ref_m-q.html#max_method">max</a> method
<!------------------------------------------------------------------------------------------------>
<hr>
<a name="name_property"><h2>name property</h2></a>
<p>
A string specifying the name of an object.
<h3>Syntax</h3>
<pre>
1. <i>objectName</i>.name
2. <i>frameReference</i>.name
3. <i>frameReference</i>.frames.name
4. <i>radioName</i>[<i>index</i>].name
5. <i>selectName</i>.options.name
6. <i>windowReference</i>.name
7. <i>windowReference</i>.frames.name
</pre>
<p><i>objectName</i> is either the value of the NAME attribute of any of the objects listed below or an element in the <i>elements</i> array.
<br><i>frameReference</i> is a valid way of referring to a frame, as described in the <a href="ref_f-g.html#frame_object">frame</a> object.
<br><i>radioName</i> is the value of the NAME attribute of a radio object.
<br><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>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>
<li><a href="ref_a-c.html#button_object">button</a>, <a href="ref_a-c.html#checkbox_object">checkbox</a>, <a href="ref_f-g.html#frame_object">frame</a>, <a href="ref_h-l.html#hidden_object">hidden</a>, <a href="ref_m-q.html#password_object">password</a>, <a href="ref_r-r.html#radio_object">radio</a>, <a href="ref_r-r.html#reset_object">reset</a>, <a href="ref_s-s.html#select_object">select</a>, <a href="ref_s-s.html#submit_object">submit</a>, <a href="ref_t-z.html#text_object">text</a>, <a href="ref_t-z.html#textarea_object">textarea</a>, <a href="ref_t-z.html#window_object">window</a>
<li><a href="ref_s-s.html#select_object">options</a> array
<h3>Description</h3>
<p>The value of the name property differs between the window object and other objects.
<h4>window object</h4>
<p>The name property for the window object is represented by form 6 and form 7 of the syntax. The name property represents the value of the <i>windowName</i> argument described in the <a href="ref_t-z.html#window_object">window</a> object syntax. Both forms of the syntax represent the same value.
<p>name is a read-only property.
<h4>All other objects</h4>
<p>The name property for all objects except window is represented by forms 1 through 5 of the syntax. For all objects except window, the name property initially reflects the value of the NAME attribute. Changing the name property overrides this setting.
<p>You can set the name property at any time.
<p>The name property is the same for every radio button in a single radio object. Individual radio buttons are referenced by their position in the radio array.
<p>Do not confuse the name property with the label displayed on a button, reset, or submit object. The value property specifies the label for these objects. The name property is not displayed onscreen; it is used to reference the objects programatically.
<p>For a select object, the values specified by form 1 and form 5 of the syntax are the same. For a frame object, the values specified by forms 1, 2, and 3 of the syntax are the same.
<p>If multiple objects on the same form have the same NAME attribute, an array of the given name is created automatically. Each element in the array represents an individual form object. Elements are indexed in source order starting at 0. For example, if two text elements and a textarea element on the same form have their NAME attribute set to "myField", an array with the elements myField[0], myField[1], and myField[2] is created.
<h3>Examples</h3>
<p>In the following example, the <i>valueGetter()</i> function uses a <b>for</b> loop to iterate over the array of elements on the <i>valueTest</i> form. The <i>msgWindow</i> window displays the names of all the elements on the form:
<pre>
newWindow=window.open("http://www.netscape.com")
function valueGetter() {
var msgWindow=window.open("")
for (var i = 0; i < newWindow.document.valueTest.elements.length; i++) {
msgWindow.document.write(newWindow.document.valueTest.elements[i].name + "<BR;>")
}
}
</pre>
In the following example, the first statement creates a window called <i>netscapeWin</i>. The second statement displays the value "netscapeHomePage" in the alert dialog box, because "netscapeHomePage" is the value of the <i>windowName</i> argument of <i>netscapeWin</i>.
<pre>
netscapeWin=window.open("http://www.netscape.com", "netscapeHomePage")
alert(netscapeWin.name)
</pre>
<h3>See also</h3>
<p>For button, reset, and submit:
<li><a href="ref_t-z.html#value_property">value</a> property
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="navigator_object"><h2>navigator object</h2></a>
<p>Contains information about the version of Navigator in use.
<h3>Syntax</h3>
<p>To use a navigator object:
<pre>
navigator.<i>propertyName</i>
</pre>
<i>propertyName</i> is one of the properties listed below.
<h3>Property of</h3>
<li>None.
<h3>Description</h3>
<p>Use the navigator object to determine which version of the Navigator your users have.
<h3>Properties</h3>
<li><a href="ref_a-c.html#appCodeName_property">appCodeName</a> specifies the code name of the browser
<li><a href="ref_a-c.html#appName_property">appName</a> specifies the name of the browser
<li><a href="ref_a-c.html#appVersion_property">appVersion</a> specifies version information for the Navigator
<li><a href="ref_t-z.html#userAgent_property">userAgent</a> specifies the user-agent header
<h3>Methods</h3>
<li>None.
<h3>Event handlers</h3>
<li>None.
<h3>Examples</h3>
<p>See the examples for the individual properties.
<h3>See also</h3>
<li><a href="ref_h-l.html#link_object">link</a> object
<li><a href="ref_a-c.html#anchor_object">anchors</a> object
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="onBlur_event"><h2>onBlur event handler</h2></a>
<p>A blur event occurs when a select, text, or textarea field on a form loses focus. The onBlur event handler executes JavaScript code when a blur event occurs.
<p>See the relevant objects for the onBlur syntax.
<h3>Event Handler of</h3>
<p><a href="ref_s-s.html#select_object">select</a>, <a href="ref_t-z.html#text_object">text</a>, <a href="ref_t-z.html#textarea_object">textarea</a>
<h3>Examples</h3>
<p>In the following example, <i>userName</i> is a required text field. When a user attempts to leave the field, the onBlur event handler calls the required() function to confirm that <i>userName</i> has a legal value.
<pre><INPUT; TYPE="text" VALUE="" NAME="userName" onBlur="required(this.value)"></pre>
<h3>See also</h3>
<li> <a href="ref_m-q.html#onChange_event">onChange</a> , <a href="ref_m-q.html#onFocus_event">onFocus</a> event handlers
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="onChange_event"><h2>onChange event handler</h2></a>
<p>A change event occurs when a select, text, or textarea field loses focus and its value has been modified. The onChange event handler executes JavaScript code when a change event occurs.
<p>Use the onChange event handler to validate data after it is modified by a user.
<p>See the relevant objects for the onChange syntax.
<h3>Event Handler of</h3>
<p><a href="ref_s-s.html#select_object">select</a>, <a href="ref_t-z.html#text_object">text</a>, <a href="ref_t-z.html#textarea_object">textarea</a>
<h3>Examples</h3>
<p>In the following example, <i>userName</i> is a text field. When a user attempts to leave the field, the onBlur event handler calls the checkValue() function to confirm that <i>userName</i> has a legal value.
<pre><INPUT; TYPE="text" VALUE="" NAME="userName" onBlur="checkValue(this.value)"></pre>
<h3>See also</h3>
<li> <a href="ref_m-q.html#onBlur_event">onBlur</a> , <a href="ref_m-q.html#onFocus_event">onFocus</a> event handlers
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="onClick_event"><h2>onClick event handler</h2></a>
<p>
A click event occurs when an object on a form is clicked. The onClick event handler executes JavaScript code when a click event occurs.
<p>See the relevant objects for the onClick syntax.
<h3>Event Handler of</h3>
<p><a href="ref_a-c.html#button_object">button</a>, <a href="ref_a-c.html#checkbox_object">checkbox</a>, <a href="ref_r-r.html#radio_object">radio</a>, <a href="ref_h-l.html#link_object">link</a>, <a href="ref_r-r.html#reset_object">reset</a>, <a href="ref_s-s.html#submit_object">submit</a>
<h3>Examples</h3>
<p>
For example, suppose you have created a JavaScript function called compute(). You can execute the compute() function when the user clicks a button by calling the function in the onClick event handler, as follows:
<pre><INPUT; TYPE="button;" VALUE="Calculate;" onClick="compute;(this.form)"></pre>
<p>In the above example, the keyword <i>this</i> refers to the current object; in this case, the Calculate button. The construct <i>this.form</i> refers to the form containing the button.
<p>For another example, suppose you have created a JavaScript function called pickRandomURL() that lets you select a URL at random. You can use the onClick event handler of a link to specify a value for the HREF attribute of the <A;> tag dynamically, as shown in the following example:
<xmp><a href="" onclick="this.href=pickRandomURL()" onmouseover="window.status='Pick a random URL'; return true">
Go!</a></xmp>
<p>In the above example, the onMouseOver event handler specifies a custom message for the Navigator status bar when the user places the mouse pointer over the Go! anchor. As this example shows, you must return true to set the window.status property in the onMouseOver event handler.
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="onFocus_event"><h2>onFocus event handler</h2></a>
<p>
A focus event occurs when a field receives input focus by tabbing with the keyboard or clicking with the mouse. Selecting within a field results in a select event, not a focus event. The onFocus event handler executes JavaScript code when a focus event occurs.
<p>See the relevant objects for the onFocus syntax.
<h3>Event Handler of</h3>
<p><a href="ref_s-s.html#select_object">select</a>, <a href="ref_t-z.html#text_object">text</a>, <a href="ref_t-z.html#textarea_object">textarea</a>
<h3>Examples</h3>
<p>The following example uses an onFocus handler in the <i>valueField</i> textarea object to call the valueCheck() function.
<pre><INPUT; TYPE="textarea" VALUE="" NAME="valueField" onFocus="valueCheck()"></pre>
<h3>See also</h3>
<li> <a href="ref_m-q.html#onBlur_event">onBlur</a> , <a href="ref_m-q.html#onChange_event">onChange</a> event handlers
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="onLoad_event"><h2>onLoad event handler</h2></a>
<p>A load event occurs when Navigator finishes loading a window or all frames within a <FRAMESET;>.; The onLoad event handler executes JavaScript code when a load event occurs.
<p>Use the onLoad event handler within either the <BODY;> or the <FRAMESET;> tag, for example, <tt><BODY; onLoad="..."></tt>.
<p>In a <FRAMESET;> and <FRAME;> relationship, an onLoad event within a frame (placed in the <BODY;> tag) occurs before an onLoad event within the <FRAMESET;> (placed in the <FRAMESET;> tag).
<h3>Event Handler of</h3>
<p><a href="ref_t-z.html#window_object">window</a>
<h3>Examples</h3>
<p>In the following example, the onLoad event handler displays a greeting message after a web page is loaded.
<pre>
<BODY; onLoad="window.alert("Welcome to the Brave New World home page!")>
</pre>
<h3>See also</h3>
<p><a href="ref_m-q.html#onUnload_event">onUnload</a> event handler
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="onMouseOver_event"><h2>onMouseOver event handler</h2></a>
<p>
<p>A mouseOver event occurs once each time the mouse pointer moves over an object from outside that object. The onMouseOver event handler executes JavaScript code when a mouseOver event occurs.
<p>You must return true within the event handler if you want to set the status or defaultStatus properties with the onMouseOver event handler.
<p>See the relevant objects for the onMouseOver syntax.
<h3>Event Handler of</h3>
<p><a href="ref_h-l.html#link_object">link</a>
<h3>Examples</h3>
<p>
By default, the HREF value of an anchor displays in the status bar at the bottom of the Navigator when a user places the mouse pointer over the anchor. In the following example, the onMouseOver event handler provides the custom message "Click this if you dare."
<xmp><a href="https://web.archive.org/web/19970617232705/http://home.netscape.com/" onmouseover="window.status='Click this if you dare!'; return true">
Click me</a></xmp>
<p>See <a href="ref_m-q.html#onClick_event">onClick</a> for an example of using onMouseOver when the <A;> tag's HREF attribute is set dynamically.
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="onSelect_event"><h2>onSelect event handler</h2></a>
<p>
<p>A select event occurs when a user selects some of the text within a text or textarea field. The onSelect event handler executes JavaScript code when a select event occurs.
<p>See the relevant objects for the onSelect syntax.
<h3>Event Handler of</h3>
<p><a href="ref_t-z.html#text_object">text</a>, <a href="ref_t-z.html#textarea_object">textarea</a>
<h3>Examples</h3>
<p>The following example uses an onSelect handler in the <i>valueField</i> text object to call the selectState() function.
<pre><INPUT; TYPE="text" VALUE="" NAME="valueField" onSelect="selectState()"></pre>
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="onSubmit_event"><h2>onSubmit event handler</h2></a>
<p>
A submit event occurs when a user submits a form. The onSubmit event handler executes JavaScript code when a submit event occurs.
<p>You can use the onSubmit event handler to prevent a form from being submitted; to do so, put a <b>return</b> statement that returns false in the event handler. Any other returned value lets the form submit. If you omit the <b>return</b> statement, the form is submitted.
<p>See the relevant objects for the onSubmit syntax.
<h3>Event Handler of</h3>
<p><a href="ref_f-g.html#form_object">form</a>
<h3>Examples</h3>
<p>In the following example, the onSubmit event handler calls the formData() function to evaluate the data being submitted. If the data is valid, the form is submitted; otherwise, the form is not submitted.
<pre>
form.onSubmit="return formData(this)"
</pre>
<p>See also the examples for the <a href="ref_f-g.html#form_object">form</a> object.
<h3>See also</h3>
<li><a href="ref_s-s.html#submit_object">submit</a> object
<li><a href="ref_s-s.html#submit_method">submit</a> method
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="onUnload_event"><h2>onUnload event handler</h2></a>
<p>An unload event occurs when you exit a document. The onUnload event handler executes JavaScript code when an unload event occurs.
<p>Use the onUnload event handler within either the <BODY;> or the <FRAMESET;> tag, for example, <tt><BODY; onUnload="..."></tt>.
<p>In a <FRAMESET;> and <FRAME;> relationship, an onUnload event within a frame (placed in the <BODY;> tag) occurs before an onUnload event within the <FRAMESET;> (placed in the <FRAMESET;> tag).
<h3>Event Handler of</h3>
<p><a href="ref_t-z.html#window_object">window</a>
<h3>Examples</h3>
<p>In the following example, the onUnload event handler calls the cleanUp() function to perform some shut down processing when the user exits a web page:
<pre>
<BODY; onUnload="cleanUp()">
</pre>
<h3>See also</h3>
<p><a href="ref_m-q.html#onLoad_event">onLoad</a> event handler
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="open_document_method"><h2>open method (document object)</h2></a>
<p>
Opens a stream to collect the output of write or writeln methods.
<h3>Syntax</h3>
<pre>document.open(["<i>mimeType</i>"])</pre>
<p>
<i>mimeType</i> specifies any of the following document types:
<pre>
text/html
text/plain
image/gif
image/jpeg
image/x-bitmap
<i>plugIn</i>
</pre>
<i>plugIn</i> is any two-part plug-in MIME type that Netscape supports.
<h3>Method of</h3>
<p><a href="ref_d-e.html#document_object">document</a>
<h3>Description</h3>
<p>The open method opens a stream to collect the output of write or writeln methods. If the <i>mimeType</i> is text or image, the stream is opened to layout; otherwise, the stream is opened to a plug-in. If a document exists in the target window, the open method clears it.
<p>End the stream by using the document.close() method. The close method causes text or images that were sent to layout to display. After using document.close(), issue document.open() again when you want to begin another output stream.
<p><i>mimeType</i> is an optional argument that specifies the type of document to which you are writing. If you do not specify a <i>mimeType</i>, the open method assumes <tt>text/html</tt> by default.
<p>Following is a description of <i>mimeType</i>:
<li><i>text/html</i> specifies a document containing ASCII text with HTML formatting.
<li><i>text/plain</i> specifies a document containing plain ASCII text with end-of-line characters to delimit displayed lines.
<li><i>image/gif</i> specifies a document with encoded bytes constituting a GIF header and pixel data.
<li><i>image/jpeg</i> specifies a document with encoded bytes constituting a JPEG header and pixel data.
<li><i>image/x-bitmap</i> specifies a document with encoded bytes constituting a bitmap header and pixel data.
<li><i>plugIn</i> loads the specified plug-in and uses it as the destination for write and writeln methods. For example, "x-world/vrml" loads the VR Scout VRML plug-in from Chaco Communications, and "application/x-director" loads the Macromedia Shockwave plug-in.
<h3>Examples</h3>
The following function calls document.open() to open a stream before issuing a write method:
<pre>
function windowWriter1() {
var myString = "Hello, world!"
msgWindow.document.open()
msgWindow.document.write("<P;>" + myString)
msgWindow.document.close()
}
</pre>
In the following example, the <i>probePlugIn()</i> function determines whether a user has the Shockwave plug-in installed:
<pre>
function probePlugIn(mimeType) {
var havePlugIn = false
var tiny = window.open("", "teensy", "width=1,height=1")
if (tiny != null) {
if (tiny.document.open(mimeType) != null)
havePlugIn = true
tiny.close()
}
return havePlugIn
}
var haveShockwavePlugIn = probePlugIn("application/x-director")
</pre>
<h3>See also</h3>
<li><a href="ref_a-c.html#clear_method">clear</a>, <a href="ref_a-c.html#close_document_method">close</a>, <a href="ref_t-z.html#write_method">write</a>, <a href="ref_t-z.html#writeln_method">writeln</a> methods
<!------------------------------------------------------------------------------------------------>
<hr>
<a name="open_window_method"><h2>open method (window object)</h2></a>
<p>
Opens a new web browser window.
<h3>Syntax</h3>
<pre>
[<i>windowVar</i> = ][window].open("<i>URL</i>", "<i>windowName</i>", ["<i>windowFeatures</i>"])
</pre>
<p><i>windowVar</i> is the name of a new window. Use this variable when referring to a window's properties, methods, and containership.
<br><i>URL</i> specifies the URL to open in the new window. See the <a href="ref_h-l.html#location_object">location</a> object for a description of the URL components.
<br><i>windowName</i> is the window name to use in the TARGET attribute of a <FORM;> or <A;> tag. <i>windowName</i> can contain only alphanumeric or underscore (_) characters.
<br><i>windowFeatures</i> is a comma-separated list of any of the following options and values:
<pre>
toolbar[=yes|no]|[=1|0]
location[=yes|no]|[=1|0]
directories[=yes|no]|[=1|0]
status[=yes|no]|[=1|0]
menubar[=yes|no]|[=1|0]
scrollbars[=yes|no]|[=1|0]
resizable[=yes|no]|[=1|0]
width=<i>pixels</i>
height=<i>pixels</i>
</pre>
<p>You may use any subset of these options. Separate options with a comma. Do not put spaces between the options.
<p><i>pixels</i> is a positive integer specifying the dimension in pixels.
<h3>Method of</h3>
<p><a href="ref_t-z.html#window_object">window</a>
<h3>Description</h3>
<p>The open method opens a new web browser window on the client, similar to choosing New Web Browser from the File menu of the Navigator. The <i>URL</i> argument specifies the URL contained by the new window. If <i>URL</i> is an empty string, a new, empty window is created.
<p>In event handlers, you must specify window.open() instead of simply using open(). Due to the scoping of static objects in JavaScript, a call to open() without specifying an object name is equivalent to document.open().
<p><i>windowFeatures</i> is an optional, comma-separated list of options for the new window. The boolean <i>windowFeatures</i> options are set to true if they are specified without values, or as <tt>yes</tt> or <tt>1</tt>. For example, <tt>open("", "messageWindow", "toolbar")</tt> and <tt>open("", "messageWindow", "toolbar=1")</tt> both set the toolbar option to true. If <i>windowName</i> does not specify an existing window and you do not specify <i>windowFeatures</i>, all boolean <i>windowFeatures</i> are true by default. If you specify any item in <i>windowFeatures</i>, all other Boolean <i>windowFeatures</i> are false unless you explicitly specify them.
<p>Following is a description of the <i>windowFeatures</i>:
<li><i>toolbar</i> creates the standard Navigator toolbar, with buttons such as "Back" and "Forward", if true
<li><i>location</i> creates a Location entry field, if true
<li><i>directories</i> creates the standard Navigator directory buttons, such as "What's New" and "What's Cool", if true
<li><i>status</i> creates the status bar at the bottom of the window, if true
<li><i>menubar</i> creates the menu at the top of the window, if true
<li><i>scrollbars</i> creates horizontal and vertical scrollbars when the document grows larger than the window dimensions, if true
<li><i>resizable</i> allows a user to resize the window, if true
<li><i>width</i> specifies the width of the window in pixels
<li><i>height</i> specifies the height of the window in pixels
<h3>Examples</h3>
<p>In the following example, the windowOpener function opens a window and uses write methods to display a message:
<pre>function windowOpener() {
msgWindow=window.open("","displayWindow","menubar=yes")
msgWindow.document.write
("<HEAD;><TITLE;>Message; window</TITLE></HEAD>")
msgWindow.document.write
("<CENTER;><BIG;><B;>Hello;, world!</B></BIG></CENTER>")
}
</pre>
<p>
The following is an onClick event handler that opens a new client window displaying the content specified in the file <i>sesame.html</i>. The window opens with the specified option settings; all other options are false because they are not specified.
<xmp>
<form name="myform">
<input type="button" name="Button1" value="Open Sesame!" onclick="window.open
('sesame.html', 'newWin', 'scrollbars=yes,status=yes,width=300,height=300')">
</form>
</xmp>
<p>
Notice the use of single quotes (') inside the onClick event handler.
<h3>See also</h3>
<li><a href="ref_a-c.html#close_window_method">close</a> method
<!------------------------------------------------------------------------------------------------>
<hr>
<a name="options_property"><h2>options property</h2></a>
<p>An array corresponding to options in a select object (<OPTION;> tags) in source order. See <a href="ref_s-s.html#select_object">select</a> object.
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="parent_property"><h2>parent property</h2></a>
<p>
The parent property is a synonym for a window or frame whose frameset contains the current frame.
<h3>Syntax</h3>
<pre>
1. parent.<i>propertyName</i>
2. parent.<i>methodName</i>
3. parent.<i>frameName</i>
4. parent.frames[<i>index</i>]
</pre>
<p><i>propertyName</i> is the defaultStatus, status, length, name, or parent property when the calling parent refers to a window object.
<br><i>propertyName</i> is the length, name, or parent property when the calling parent refers to a frame object.
<br><i>methodName</i> is any method associated with the window object.
<br><i>frameName</i> and frames[<i>index</i>] are ways to refer to frames.
<h3>Property of</h3>
<p><a href="ref_f-g.html#frame_object">frame</a>, <a href="ref_t-z.html#window_object">window</a>
<h3>Description</h3>
<p>The parent property refers to the <FRAMESET;> window of a frame. Child frames within a frameset refer to sibling frames by using "parent" in place of the window name as follows: <tt>parent.<i>frameName</i></tt> or <tt>parent.frames[<i>index</i>]</tt>. For example, if the fourth frame in a set has NAME="homeFrame", sibling frames can refer to that frame using <tt>parent.homeFrame</tt> or <tt>parent.frames[3]</tt>.
<p>You can use <tt>parent.parent</tt> to refer to the "grandparent" frame or window when a <FRAMESET;> tag is nested within a child frame.
<p>The parent property is read-only. The value of the parent property is
<pre> <object; <i>nameAttribute</i>></pre>
where <i>nameAttribute</i> is the NAME attribute if the parent is a frame, or an internal reference if the parent is a window.
<h3>Examples</h3>
<p>See the examples for the <a href="ref_f-g.html#frame_object">frame</a> object.
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="parse_method"><h2>parse method</h2></a>
<p>
Returns the number of milliseconds in a date string since January 1, 1970 00:00:00, local time.
<h3>Syntax</h3>
<pre>Date.parse(<i>dateString</i>)</pre>
<i>dateString</i> is a string representing a date or a property of an existing object.
<h3>Method of</h3>
<p><a href="ref_d-e.html#Date_object">Date</a>
<h3>Description</h3>
<p>
The parse method takes a date string (such as "Dec 25, 1995"), and returns the number of milliseconds since January 1, 1970 00:00:00 (local time). This function is useful for setting date values based on string values, for example in conjunction with the setTime method and the Date object.
<p>
Given a string representing a time, parse returns the time value. It accepts the IETF standard date syntax: "Mon, 25 Dec 1995 13:30:00 GMT". It understands the continental US time zone abbreviations, but for general use, use a time zone offset, for example "Mon, 25 Dec 1995 13:30:00 GMT+0430" (4 hours, 30 minutes west of the Greenwich meridian). If you do not specify a time zone, the local time zone is assumed. GMT and UTC are considered equivalent.
<p>
Because the parse function is a static method of Date, you always use it as <code>Date.parse()</code>, rather than as a method of a date object you created.
<h3>Examples</h3>
<p>
If <i>IPOdate</i> is an existing date object, then
<pre>
IPOdate.setTime(Date.parse("Aug 9, 1995"))
</pre>
<h3>See also</h3>
<li><a href="ref_t-z.html#UTC_method">UTC</a> method
<!------------------------------------------------------------------------------------------------>
<hr>
<a name="parseFloat_method"><h2>parseFloat function</h2></a>
<p>
Parses a string argument and returns a floating point number.
<h3>Syntax</h3>
<pre>parseFloat(<i>string</i>)</pre>
<p><i>string</i> is a string that represents the value you want to parse.
<h3>Description</h3>
<p>The parseFloat function is a built-in JavaScript function. It is not a method associated with any object, but is part of the language itself.
<p>parseFloat parses its argument, a string, and returns a floating point number. If it encounters a character other than a sign ( + or -), numeral (0-9), a decimal point, or an exponent, then it returns the value up to that point and ignores that character and all succeeding characters.
<p>If the first character cannot be converted to a number, parseFloat returns one of the following values:
<li>0 on Windows platforms.
<li>"NaN" on any other platform, indicating that the value is not a number.
<p>For arithmetic purposes, the "NaN" value is not a number in any radix. You can call the isNaN function to determine if the result of parseFloat is "NaN". If "NaN" is passed on to arithmetic operations, the operation results will also be "NaN".
<h3>Examples</h3>
<p>
The following examples all return 3.14:
<pre>
parseFloat("3.14")
parseFloat("314e-2")
parseFloat("0.0314E+2")
var x = "3.14"
parseFloat(x)
</pre>
<p>
The following example returns "NaN" or 0:
<pre>
parseFloat("FF2")
</pre>
<h3>See also</h3>
<li><a href="ref_h-l.html#isNaN_method">isNaN</a>, <a href="ref_m-q.html#parseInt_method">parseInt</a> functions
<!------------------------------------------------------------------------------------------------>
<hr>
<a name="parseInt_method"><h2>parseInt function</h2></a>
<p>
Parses a string argument and returns an integer of the specified radix or base.
<h3>Syntax</h3>
<pre>parseInt(<i>string</i> [,<i>radix</i>])</pre>
<p><i>string</i> is a string that represents the value you want to parse.
<br><i>radix</i> is an integer that represents the radix of the return value.
<h3>Description</h3>
<p>The parseInt 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 parseInt function parses its first argument, a string, and attempts to return an integer of the specified radix (base). For example, a radix of 10 indicates to convert to a decimal number, 8 octal, 16 hexadecimal, and so on. For radixes above 10, the letters of the alphabet indicate numerals greater than 9. For example, for hexadecimal numbers (base 16), A through F are used.
<p>If parseInt encounters a character that is not a numeral in the specified radix, it ignores it and all succeeding characters and returns the integer value parsed up to that point. ParseInt truncates numbers to integer values.
<p>If the radix is not specified or is specified as 0, JavaScript assumes the following:
<li>If the input <i>string</i> begins with "0x", the radix is 16 (hexadecimal).
<li>If the input <i>string</i> begins with "0", the radix is 8 (octal).
<li>If the input <i>string</i> begins with any other value, the radix is 10 (decimal).
<p>If the first character cannot be converted to a number, parseFloat returns one of the following values:
<li>0 on Windows platforms.
<li>"NaN" on any other platform, indicating that the value is not a number.
<p>For arithmetic purposes, the "NaN" value is not a number in any radix. You can call the isNaN function to determine if the result of parseInt is "NaN". If "NaN" is passed on to arithmetic operations, the operation results will also be "NaN".
<h3>Examples</h3>
<p>The following examples all return 15:
<pre>
parseInt("F", 16)
parseInt("17", 8)
parseInt("15", 10)
parseInt(15.99, 10)
parseInt("FXX123", 16)
parseInt("1111", 2)
parseInt("15*3", 10)
</pre>
<p>The following examples all return "NaN" or 0:
<pre>
parseInt("Hello", 8)
parseInt("0x7", 10)
parseInt("FFF", 10)
</pre>
<p>Even though the radix is specified differently, the following examples all return 17 because the input <i>string</i> begins with "0x".
<pre>
parseInt("0x11", 16)
parseInt("0x11", 0)
parseInt("0x11")
</pre>
<h3>See also</h3>
<li><a href="ref_h-l.html#isNaN_method">isNaN</a>, <a href="ref_m-q.html#parseFloat_method">parseFloat</a> functions
<!------------------------------------------------------------------------------------------------>
<hr>
<a name="password_object"><h2>password object</h2></a>
<p>A text field on an HTML form that conceals its value by displaying asterisks (*). When the user enters text into the field, asterisks (*) hide anything entered from view.
<h3>Syntax</h3>
<p>To define a password object, use standard HTML syntax:
<pre>
<INPUT;
TYPE="password"
NAME="<i>passwordName</i>"
[VALUE="<i>textValue</i>"]
SIZE=<i>integer</i>>
</pre>
<i>NAME="passwordName"</i> specifies the name of the password object. You can access this value using the name property.
<br><i>VALUE="textValue"</i> specifies the initial value of the password object. You can access this value using the defaultValue property.
<br><i>SIZE=integer</i> specifies the number of characters the password object can accommodate without scrolling.
<p>To use a password object's properties and methods:
<pre>
1. <i>passwordName</i>.<i>propertyName</i>
2. <i>passwordName</i>.<i>methodName</i>(<i>parameters</i>)
3. <i>formName</i>.elements[<i>index</i>].<i>propertyName</i>
4. <i>formName</i>.elements[<i>index</i>].<i>methodName</i>(<i>parameters</i>)
</pre>
<i>passwordName</i> is the value of the NAME attribute of a password object.
<br><i>formName</i> is either the value of the NAME attribute of a form object or an element in the <i>forms</i> array.
<br><i>index</i> is an integer representing a password object on a form.
<br><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_f-g.html#form_object">form</a>
<h3>Description</h3>
<p>A password object on a form looks as follows:
<form>
<p><b>Enter your password:</b> <input type="password" value="baylaurel" size="25">
</form>
<p>A password object is a form element and must be defined within a <FORM;> tag.
<h3>Properties</h3>
<li><a href="ref_d-e.html#defaultValue_property">defaultValue</a> reflects the VALUE attribute
<li><a href="ref_m-q.html#name_property">name</a> reflects the NAME attribute
<li><a href="ref_t-z.html#value_property">value</a> reflects the current value of the password object's field
<h3>Methods</h3>
<li><a href="ref_f-g.html#focus_method">focus</a>
<li><a href="ref_a-c.html#blur_method">blur</a>
<li><a href="ref_s-s.html#select_method">select</a>
<h3>Event handlers</h3>
<li>None.
<h3>Examples</h3>
<p>
<xmp>
<b>Password:</b> <input type="password" name="password" value="" size="25">
</xmp>
<h3>See also</h3>
<li><a href="ref_f-g.html#form_object">form</a> and <a href="ref_t-z.html#text_object">text</a> objects
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="pathname_property"><h2>pathname property</h2></a>
<p>
A string specifying the url-path portion of the URL.
<h3>Syntax</h3>
<pre>
1. links[<i>index</i>].pathname
2. location.pathname
</pre>
<p><i>index</i> is an integer representing a link object.
<h3>Property of</h3>
<p><a href="ref_h-l.html#link_object">link</a>, <a href="ref_h-l.html#location_object">location</a>
<h3>Description</h3>
<p>The pathname property specifies a portion of the URL. The pathname supplies the details of how the specified resource can be accessed.
<p>You can set the pathname property at any time, although it is safer to set the href property to change a location. If the pathname that you specify cannot be found in the current location, you will get an error.
<p>See Section 3.1 of <a href="https://web.archive.org/web/19970617232705/http://www.cis.ohio-state.edu/htbin/rfc/rfc1738.html" target="_top">RFC 1738</a> for complete information about the pathname.
<h3>Examples</h3>
<p>See the examples for the <a href="ref_h-l.html#href_property">href</a> property.
<h3>See also</h3>
<li><a href="ref_h-l.html#hash_property">hash</a>, <a href="ref_h-l.html#host_property">host</a>, <a href="ref_h-l.html#hostname_property">hostname</a>, <a href="ref_h-l.html#href_property">href</a>, <a href="ref_m-q.html#port_property">port</a>, <a href="ref_m-q.html#protocol_property">protocol</a>, <a href="ref_s-s.html#search_property">search</a> properties
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="PI_property"><h2>PI property</h2></a>
<p>
The ratio of the circumference of a circle to its diameter, approximately 3.14159.
<h3>Syntax</h3>
<pre>Math.PI</pre>
<h3>Property of</h3>
<p><a href="ref_m-q.html#Math_object">Math</a>
<h3>Description</h3>
<p>Because PI is a constant, it is a read-only property of Math.
<h3>Examples</h3>
<p>The following example displays the value of pi:
<pre>document.write("The value of pi is " + Math.PI)</pre>
<h3>See also</h3>
<li><a href="ref_d-e.html#E_property">E</a>, <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_s-s.html#SQRT1_2_property">SQRT1_2</a>, <a href="ref_s-s.html#SQRT2_property">SQRT2</a> properties
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="port_property"><h2>port property</h2></a>
<p>
A string specifying the communications port that the server uses for communications.
<h3>Syntax</h3>
<pre>
1. links[<i>index</i>].port
2. location.port
</pre>
<p><i>index</i> is an integer representing a link object.
<h3>Property of</h3>
<p><a href="ref_h-l.html#link_object">link</a>, <a href="ref_h-l.html#location_object">location</a>
<h3>Description</h3>
<p>The port property specifies a portion of the URL. The port property is a substring of the host property. The host property is the concatenation of the hostname and port properties, separated by a colon. When the port property is not defined, the host property is the same as the hostname property.
<p>You can set the port property at any time, although it is safer to set the href property to change a location. If the port that you specify cannot be found in the current location, you will get an error. If the port property is not specified, it defaults to 80 on the server.
<p>See Section 3.1 of <a href="https://web.archive.org/web/19970617232705/http://www.cis.ohio-state.edu/htbin/rfc/rfc1738.html" target="_top">RFC 1738</a> for complete information about the port.
<h3>Examples</h3>
<p>See the examples for the <a href="ref_h-l.html#href_property">href</a> property.
<h3>See also</h3>
<li><a href="ref_h-l.html#hash_property">hash</a>, <a href="ref_h-l.html#host_property">host</a>, <a href="ref_h-l.html#hostname_property">hostname</a>, <a href="ref_h-l.html#href_property">href</a>, <a href="ref_m-q.html#pathname_property">pathname</a>, <a href="ref_m-q.html#protocol_property">protocol</a>, <a href="ref_s-s.html#search_property">search</a> properties
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="pow_method"><h2>pow method</h2></a>
<p>
Returns <i>base</i> to the <i>exponent</i> power, that is, <i>base</i><sup><i>exponent</i></sup>.
<h3>Syntax</h3>
<pre>Math.pow(<i>base, exponent</i>)</pre>
<i>base</i> is any numeric expression or a property of an existing object.
<br><i>exponent</i> is any numeric expression or a property of an existing object.
If the result would include an imaginary number (for example pow(-1, 0.5)), then the value returned is
always zero.
<h3>Method of</h3>
<p><a href="ref_m-q.html#Math_object">Math</a>
<h3>Examples</h3>
<pre>
//Displays the value 49
document.write("7 to the power of 2 is " + Math.pow(7,2))
//Displays the value 1024
document.write("<P;>2; to the power of 10 is " + Math.pow(2,10))
</pre>
<h3>See also</h3>
<li><a href="ref_d-e.html#exp_method">exp</a>, <a href="ref_h-l.html#log_method">log</a> methods
<!------------------------------------------------------------------------------------------------>
<hr>
<a name="prompt_method"><h2>prompt method</h2></a>
<p>
Displays a Prompt dialog box with a message and an input field.
<h3>Syntax</h3>
<pre>prompt(<i>message</i>, [<i>inputDefault</i>])</pre>
<i>message</i> is any string or a property of an existing object; the string is displayed as the message.
<br><i>inputDefault</i> is a string, integer, or property of an existing object that represents the default value of the input field.
<h3>Method of</h3>
<p><a href="ref_t-z.html#window_object">window</a>
<h3>Description</h3>
<p>Use the prompt method to display a dialog box that receives user input. If you do not specify an initial value for <i>inputDefault</i>, the dialog box displays the value <undefined;>.;
<p>Although prompt is a method of the window object, you do not need to specify a <i>windowReference</i> when you call it. For example, <tt><i>windowReference</i>.prompt()</tt> is unnecessary.
<h3>Examples</h3>
<pre>
prompt("Enter the number of cookies you want to order:", 12)
</pre>
<h3>See also</h3>
<li><a href="ref_a-c.html#alert_method">alert</a>, <a href="ref_a-c.html#confirm_method">confirm</a> methods
<!------------------------------------------------------------------------------------------------>
<hr>
<a name="protocol_property"><h2>protocol property</h2></a>
<p>
A string specifying the beginning of the URL, up to and including the first colon.
<h3>Syntax</h3>
<pre>
1. links[<i>index</i>].protocol
2. location.protocol
</pre>
<p><i>index</i> is an integer representing a link object.
<h3>Property of</h3>
<p><a href="ref_h-l.html#link_object">link</a>, <a href="ref_h-l.html#location_object">location</a>
<h3>Description</h3>
<p>The protocol property specifies a portion of the URL. The protocol indicates the access method of the URL. For example, a protocol of "http:" specifies Hypertext Transfer Protocol, and a protocol of "javascript:" specifies JavaScript code.
<p>You can set the protocol property at any time, although it is safer to set the href property to change a location. If the protocol that you specify cannot be found in the current location, you will get an error.
<p>The protocol property represents the scheme name of the URL. See Section 2.1 of <a href="https://web.archive.org/web/19970617232705/http://www.cis.ohio-state.edu/htbin/rfc/rfc1738.html" target="_top">RFC 1738</a> for complete information about the protocol.
<h3>Examples</h3>
<p>See the examples for the <a href="ref_h-l.html#href_property">href</a> property.
<h3>See also</h3>
<li><a href="ref_h-l.html#hash_property">hash</a>, <a href="ref_h-l.html#host_property">host</a>, <a href="ref_h-l.html#hostname_property">hostname</a>, <a href="ref_h-l.html#href_property">href</a>, <a href="ref_m-q.html#pathname_property">pathname</a>, <a href="ref_m-q.html#port_property">port</a>, <a href="ref_s-s.html#search_property">search</a> properties
<!------------------------------------------------------------------------------------------------->
<hr>
<script>
document.write("<FONT SIZE=-2>Last modified " + document.lastModified)
</script>
<p>
</body>
<html>
<!--
FILE ARCHIVED ON 23:27:05 Jun 17, 1997 AND RETRIEVED FROM THE
INTERNET ARCHIVE ON 18:13:57 Nov 08, 2018.
ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C.
SECTION 108(a)(3)).
-->