-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathref_s-s.html
1185 lines (966 loc) · 48.8 KB
/
ref_s-s.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
999
1000
<html>
<body>
<a name="search_property"><h2>search property</h2></a>
<p>
A string beginning with a question mark that specifies any query information in the URL.
<h3>Syntax</h3>
<pre>
1. links[<i>index</i>].search
2. location.search
</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 search property specifies a portion of the URL.
<p>You can set the search property at any time, although it is safer to set the href property to change a location. If the search that you specify cannot be found in the current location, you will get an error.
<p>See Section 3.3 of <a href="https://web.archive.org/web/19970617232717/http://www.cis.ohio-state.edu/htbin/rfc/rfc1738.html" target="_top">RFC 1738</a> for complete information about the search.
<h3>Examples</h3>
<p>In the following example, the <tt>window.open</tt> statement creates a window called <i>newWindow</i> and loads the specified URL into it. The <tt>document.write</tt> statements display all the properties of <tt>newWindow.location</tt> in a window called <i>msgWindow</i>.
<pre>
newWindow=window.open
("http://guide-p.infoseek.com/WW/NS/Titles?qt=RFC+1738+&col;=WW")
msgWindow.document.write("newWindow.location.href = " +
newWindow.location.href + "<P;>")
msgWindow.document.write("newWindow.location.protocol = " +
newWindow.location.protocol + "<P;>")
msgWindow.document.write("newWindow.location.host = " +
newWindow.location.host + "<P;>")
msgWindow.document.write("newWindow.location.hostName = " +
newWindow.location.hostName + "<P;>")
msgWindow.document.write("newWindow.location.port = " +
newWindow.location.port + "<P;>")
msgWindow.document.write("newWindow.location.pathname = " +
newWindow.location.pathname + "<P;>")
msgWindow.document.write("newWindow.location.search = " +
newWindow.location.search + "<P;>")
msgWindow.document.write("newWindow.location.hash = " +
newWindow.location.hash + "<P;>")
msgWindow.document.close()
</pre>
<p>The previous example displays the following output:
<pre>
newWindow.location.href =
http://guide-p.infoseek.com/WW/NS/Titles?qt=RFC+1738+&col;=WW
newWindow.location.protocol = http:
newWindow.location.host = guide-p.infoseek.com
newWindow.location.hostName = guide-p.infoseek.com
newWindow.location.port =
newWindow.location.pathname = /WW/NS/Titles
newWindow.location.search = ?qt=RFC+1738+&col;=WW
newWindow.location.hash =
</pre>
<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_m-q.html#protocol_property">protocol</a> properties
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="select_method"><h2>select method</h2></a>
<p>
Selects the input area of the specified password, text, or textarea object.
<h3>Syntax</h3>
<pre>
1. <i>passwordName</i>.select()
2. <i>textName</i>.select()
3. <i>textareaName</i>.select()
</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>Method 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>Use the select method to highlight the input area of a form element. You can use the select method with the focus method to highlight a field and position the cursor for a user response.
<h3>Examples</h3>
<p>In the following example, the <i>checkPassword</i> function confirms that a user has entered a valid password. If the password is not valid, the select method highlights the password field and the focus method returns focus to it so the user can re-enter the password.
<pre>
function checkPassword(userPass) {
if (badPassword) {
alert("Please enter your password again.")
userPass.focus()
userPass.select()
}
}</pre>
This example assumes that the password is defined as:
<pre><INPUT; TYPE="password" NAME="userPass"></pre>
<h3>See also</h3>
<li><a href="ref_a-c.html#blur_method">blur</a>, <a href="ref_f-g.html#focus_method">focus</a> methods
<!------------------------------------------------------------------------------------------------>
<hr>
<a name="select_object"><h2>select object (<i>options</i> array)</h2></a>
<p>A selection list or scrolling list on an HTML form. A selection list lets the user choose one item from a list. A scrolling list lets the user choose one or more items from a list.
<h3>Syntax</h3>
<p>To define a select object, use standard HTML syntax with the addition of the onBlur, onChange, and onFocus event handlers:
<pre>
<SELECT;
NAME="<i>selectName</i>"
[SIZE="<i>integer</i>"]
[MULTIPLE]
[onBlur="<i>handlerText</i>"]
[onChange="<i>handlerText</i>"]
[onFocus="<i>handlerText</i>"]>
<OPTION; VALUE="<i>optionValue</i>" [SELECTED]> <i>textToDisplay</i> [ ... <OPTION;> <i>textToDisplay</i>]
</SELECT>
</pre>
<i>NAME="selectName"</i> specifies the name of the select object. You can access this value using the name property.
<br><i>SIZE="integer"</i> specifies the number of options visible when the form is displayed.
<br><i>MULTIPLE</i> specifies that the select object is a scrolling list (not a selection list).
<br><i>OPTION</i> specifies a selection element in the list. You can access the options using the options array.
<br><i>VALUE="optionValue"</i> specifies a value that is returned to the server when the option is selected and the form is submitted. You can access this value using the value property.
<br><i>SELECTED</i> specifies that the option is selected by default. You can access this value using the defaultSelected property.
<br><i>textToDisplay</i> specifies the text to display in the list. You can access this value using the text property.
<p>To use a select object's properties and methods:
<pre>
1. <i>selectName</i>.<i>propertyName</i>
2. <i>selectName</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>selectName</i> is the value of the NAME attribute of a select 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 select 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.
<p>To use an option's properties:
<pre>
1. <i>selectName</i>.options[<i>index1</i>].<i>propertyName</i>
2. <i>formName</i>.elements[<i>index2</i>].options[<i>index1</i>].<i>propertyName</i>
</pre>
<i>selectName</i> is the value of the NAME attribute of a select object.
<br><i>index1</i> is an integer representing an option in a select 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>index2</i> is an integer representing a select object on a form.
<br><i>propertyName</i> is one of the properties listed below.
<h3>Property of</h3>
<li>The select object is a property of <a href="ref_f-g.html#form_object">form</a>
<li>The options array is a property of <a href="ref_s-s.html#select_object">select</a>
<h3>Description</h3>
<p>A select object on a form looks as follows. The object on the left is a selection list that lets the user choose one item; the object on the right is a scrolling list that lets the user choose one or more items:
<form>
<select name="music_type_single">
<option selected> R&B;
<option> Jazz
<option> Blues
<option> New Age
</select>
<select name="music_type_multi" multiple>
<option selected> R&B;
<option> Jazz
<option> Blues
<option> New Age
</select>
</form>
<p>A select object is a form element and must be defined within a <FORM;> tag.
<h4>The <i>options</i> array</h4>
<p>You can reference the options of a select object in your code by using the <i>options</i> array. This array contains an entry for each option in a select object (<OPTION;> tag) in source order. For example, if a select object named <i>musicStyle</i> contains three options, these options are reflected as <tt>musicStyle.options[0]</tt>, <tt>musicStyle.options[1]</tt>, and <tt>musicStyle.options[2]</tt>.
<p>To use the <i>options</i> array:
<pre>
1. <i>selectName</i>.options
2. <i>selectName</i>.options[<i>index</i>]
3. <i>selectName</i>.options.length
</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.
<p>To obtain the number of options in a select object, use the length property of either the options array or the select object:
<pre>
1. <i>selectName</i>.length
2. <i>selectName</i>.options.length
</pre>
<p>The select object has properties that you can access only through the options array. These properties are listed below.
<p>Even though each element in the <i>options</i> array represents a select option, the value of options[<i>index</i>] is always null. The value returned by <i>selectName</i>.options represents the full HTML statement for the <i>selectName</i> object.
<p>Elements in the <i>options</i> array are read-only. For example, the statement <tt><i>selectName</i>.options[0]="guitar"</tt> has no effect.
<h3>Properties</h3>
<p>The select object has the following properties:
<li><a href="ref_h-l.html#length_property">length</a> reflects the number of options in a select object
<li><a href="ref_m-q.html#name_property">name</a> reflects the NAME attribute
<li><a href="ref_s-s.html#select_object">options</a> reflects the <OPTION;> tags
<li><a href="ref_s-s.html#selectedIndex_property">selectedIndex</a> reflects the index of the selected option (or the first selected option, if multiple options are selected)
<p>The <i>options</i> array has the following properties:
<li><a href="ref_d-e.html#defaultSelected_property">defaultSelected</a> reflects the SELECTED attribute
<li><a href="ref_h-l.html#index_property">index</a> reflects the index of an option
<li><a href="ref_h-l.html#length_property">length</a> reflects the number of options in a select object
<li><a href="ref_m-q.html#name_property">name</a> reflects the NAME attribute
<li><a href="ref_s-s.html#selected_property">selected</a> lets you programatically select an option
<li><a href="ref_s-s.html#selectedIndex_property">selectedIndex</a> reflects the index of the selected option
<li><a href="ref_t-z.html#text_property">text</a> reflects the <i>textToDisplay</i> that follows an <OPTION;> tag
<li><a href="ref_t-z.html#value_property">value</a> reflects the VALUE attribute
<h3>Methods</h3>
<li><a href="ref_a-c.html#blur_method">blur</a>
<li><a href="ref_f-g.html#focus_method">focus</a>
<h3>Event handlers</h3>
<li><a href="ref_m-q.html#onBlur_event">onBlur</a>
<li><a href="ref_m-q.html#onChange_event">onChange</a>
<li><a href="ref_m-q.html#onFocus_event">onFocus</a>
<h3>Examples</h3>
<p><b>Example 1.</b> The following example displays a selection list and a scrolling list.
<xmp>
Choose the music type for your free CD:
<select name="music_type_single">
<option selected> R&B;
<option> Jazz
<option> Blues
<option> New Age
</select>
<p>Choose the music types for your free CDs:
<br><select name="music_type_multi" multiple>
<option selected> R&B;
<option> Jazz
<option> Blues
<option> New Age
</select>
</xmp>
<p><b>Example 2.</b> The following example displays two selection lists that let the user choose a month and day. These selection lists are initialized to the current date. The user can change the month and day by using the selection lists or by choosing preset dates from radio buttons. Text fields on the form display the values of the select object's properties and indicate the date chosen and whether it is Cinco de Mayo.
<xmp>
<html>
<head>
<title>Select object example</title>
</head>
<body>
<script>
var today = new Date()
//---------------
function updatePropertyDisplay(monthObj,dayObj) {
// Get date strings
var monthInteger, dayInteger, monthString, dayString
monthInteger=monthObj.selectedIndex
dayInteger=dayObj.selectedIndex
monthString=monthObj.options[monthInteger].text
dayString=dayObj.options[dayInteger].text
// Display property values
document.selectForm.textFullDate.value=monthString + " " + dayString
document.selectForm.textMonthLength.value=monthObj.length
document.selectForm.textDayLength.value=dayObj.length
document.selectForm.textMonthName.value=monthObj.name
document.selectForm.textDayName.value=dayObj.name
document.selectForm.textMonthIndex.value=monthObj.selectedIndex
document.selectForm.textDayIndex.value=dayObj.selectedIndex
// Is it Cinco de Mayo?
if (monthObj.options[4].selected && dayObj.options[4].selected)
document.selectForm.textCinco.value="Yes!"
else
document.selectForm.textCinco.value="No"
}
</script>
<!--------------->
<form name="selectForm">
<p><b>Choose a month and day:</b>
Month: <select name="monthSelection" onchange="updatePropertyDisplay(this,document.selectForm.daySelection)">
<option> January <option> February <option> March
<option> April <option> May <option> June
<option> July <option> August <option> September
<option> October <option> November <option> December
</select>
Day: <select name="daySelection" onchange="updatePropertyDisplay(document.selectForm.monthSelection,this)">
<option> 1 <option> 2 <option> 3 <option> 4 <option> 5
<option> 6 <option> 7 <option> 8 <option> 9 <option> 10
<option> 11 <option> 12 <option> 13 <option> 14 <option> 15
<option> 16 <option> 17 <option> 18 <option> 19 <option> 20
<option> 21 <option> 22 <option> 23 <option> 24 <option> 25
<option> 26 <option> 27 <option> 28 <option> 29 <option> 30
<option> 31
</select>
<p><b>Set the date to: </b>
<input type="radio" name="dateChoice" onclick="
monthSelection.selectedIndex=0;
daySelection.selectedIndex=0;
updatePropertyDisplay(document.selectForm.monthSelection,document.selectForm.daySelection)">
New Year's Day
<input type="radio" name="dateChoice" onclick="
monthSelection.selectedIndex=4;
daySelection.selectedIndex=4;
updatePropertyDisplay(document.selectForm.monthSelection,document.selectForm.daySelection)">
Cinco de Mayo
<input type="radio" name="dateChoice" onclick="
monthSelection.selectedIndex=5;
daySelection.selectedIndex=20;
updatePropertyDisplay(document.selectForm.monthSelection,document.selectForm.daySelection)">
Summer Solstice
<p><b>Property values:</b>
<br>Date chosen: <input type="text" name="textFullDate" value="" size="20"">
<br>monthSelection.length<input type="text" name="textMonthLength" value="" size="20"">
<br>daySelection.length<input type="text" name="textDayLength" value="" size="20"">
<br>monthSelection.name<input type="text" name="textMonthName" value="" size="20"">
<br>daySelection.name<input type="text" name="textDayName" value="" size="20"">
<br>monthSelection.selectedIndex<input type="text" name="textMonthIndex" value="" size="20"">
<br>daySelection.selectedIndex<input type="text" name="textDayIndex" value="" size="20"">
<br>Is it Cinco de Mayo? <input type="text" name="textCinco" value="" size="20"">
<script>
document.selectForm.monthSelection.selectedIndex=today.getMonth()
document.selectForm.daySelection.selectedIndex=today.getDate()-1
updatePropertyDisplay(document.selectForm.monthSelection,document.selectForm.daySelection)
</script>
</form>
</body>
</html>
</xmp>
<p>See also the examples for the <a href="ref_d-e.html#defaultSelected_property">defaultSelected</a> property.
<h3>See also</h3>
<li><a href="ref_f-g.html#form_object">form</a> and <a href="ref_r-r.html#radio_object">radio</a> objects
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="selected_property"><h2>selected property</h2></a>
<p>
A Boolean value specifying the current selection state of an option in a select object.
<h3>Syntax</h3>
<pre><i>selectName</i>.options[<i>index</i>].selected</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, the value of its selected property is true; otherwise, it is false.
<p>You can set the selected property at any time. The display of the select object updates immediately when you set the selected property.
<p>In general, the selected property is more useful than the selectedIndex property for select objects that are created with the MULTIPLE attribute. With the selected property, you can evaluate every option in the <i>options</i> array to determine multiple selections, and you can select individual options without clearing the selection of other options.
<h3>Examples</h3>
<p>See the examples for the <a href="ref_d-e.html#defaultSelected_property">defaultSelected</a> property.
<h3>See also</h3>
<li><a href="ref_d-e.html#defaultSelected_property">defaultSelected</a>, <a href="ref_h-l.html#index_property">index</a>, <a href="ref_s-s.html#selectedIndex_property">selectedIndex</a> properties
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="selectedIndex_property"><h2>selectedIndex property</h2></a>
<p>
An integer specifying the index of the selected option in a select object.
<h3>Syntax</h3>
<pre>
1. <i>selectName</i>.selectedIndex
2. <i>selectName</i>.options.selectedIndex
</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.
<h3>Property of</h3>
<li><a href="ref_s-s.html#select_object">select</a>
<li><a href="ref_s-s.html#select_object">options</a> array
<h3>Description</h3>
<p>Options in a select object are indexed in the order in which they are defined, starting with an index of 0. You can set the selectedIndex property at any time. The display of the select object updates immediately when you set the selectedIndex property. Both forms of the syntax specify the same value.
<p>In general, the selectedIndex property is more useful for select objects that are created without the MULTIPLE attribute. If you evaluate selectedIndex when multiple options are selected, the selectedIndex property specifies the index of the first option only. Setting selectedIndex clears any other options that are selected in the select object.
<p>The selected property of the select object's <i>options</i> array is more useful for select objects that are created with the MULTIPLE attribute. With the selected property, you can evaluate every option in the <i>options</i> array to determine multiple selections, and you can select individual options without clearing the selection of other options.
<h3>Examples</h3>
<p>In the following example, the <i>getSelectedIndex()</i> function returns the selected index in the <i>musicType</i> select object:
<pre>
function getSelectedIndex() {
return document.musicForm.musicType.selectedIndex
}
</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_d-e.html#defaultSelected_property">defaultSelected</a>, <a href="ref_h-l.html#index_property">index</a>, <a href="ref_s-s.html#selected_property">selected</a> properties
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="self_property"><h2>self property</h2></a>
<p>
The self property is a synonym for the current window or frame.
<h3>Syntax</h3>
<pre>
1. self.<i>propertyName</i>
2. self.<i>methodName</i>
</pre>
<p><i>propertyName</i> is the defaultStatus, status, length, or name property when self refers to a window object.
<br><i>propertyName</i> is the length or name property when self refers to a frame object.
<br><i>methodName</i> is any method associated with the window object.
<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 self property refers to the current window or frame.
<p>Use the self property to disambiguate a window property from a form or form element of the same name. You can also use the self property to make your code more readable.
<p>The self property is read-only. The value of the self property is
<pre> <object; <i>nameAttribute</i>></pre>
where <i>nameAttribute</i> is the NAME attribute if self refers to a frame, or an internal reference if self refers to a window.
<h3>Examples</h3>
<p>In the following example, <tt>self.status</tt> is used to set the status property of the current window. This usage disambiguates the status property of the current window from a form or form element called "status" within the current window.
<xmp><a href="" onclick="this.href=pickRandomURL()" onmouseover="self.status='Pick a random URL' ; return true">
Go!</a></xmp>
<h3>See also</h3>
<li><a href="ref_t-z.html#window_property">window</a> property
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="setDate_method"><h2>setDate method</h2></a>
<p>
Sets the day of the month for a specified date.
<h3>Syntax</h3>
<pre><i>dateObjectName</i>.setDate(<i>dayValue</i>)</pre>
<p><i>dateObjectName</i> is either the name of a date object or a property of an existing object.
<br><i>dayValue</i> is an integer from 1 to 31 or a property of an existing object, representing the day of the month.
<h3>Method of</h3>
<p><a href="ref_d-e.html#Date_object">Date</a>
<h3>Examples</h3>
<p>
The second statement below changes the day for <i>theBigDay</i> to the 24th of July from its original value.
<pre>
theBigDay = new Date("July 27, 1962 23:30:00")
theBigDay.setDate(24)
</pre>
<h3>See also</h3>
<li><a href="ref_f-g.html#getDate_method">getDate</a> method
<!------------------------------------------------------------------------------------------------>
<hr>
<a name="setHours_method"><h2>setHours method</h2></a>
<p>
Sets the hours for a specified date.
<h3>Syntax</h3>
<pre><i>dateObjectName</i>.setHours(<i>hoursValue</i>)</pre>
<p><i>dateObjectName</i> is either the name of a date object or a property of an existing object.
<br><i>hoursValue</i> is an integer between 0 and 23 or a property of an existing object, representing the hour.
<h3>Method of</h3>
<p><a href="ref_d-e.html#Date_object">Date</a>
<h3>Examples</h3>
<pre>
theBigDay.setHours(7)
</pre>
<h3>See also</h3>
<li><a href="ref_f-g.html#getHours_method">getHours</a> method
<!------------------------------------------------------------------------------------------------>
<hr>
<a name="setMinutes_method"><h2>setMinutes method</h2></a>
<p>
Sets the minutes for a specified date.
<h3>Syntax</h3>
<pre><i>dateObjectName</i>.setMinutes(<i>minutesValue</i>)</pre>
<p><i>dateObjectName</i> is either the name of a date object or a property of an existing object.
<br><i>minutesValue</i> is an integer between 0 and 59 or a property of an existing object, representing the minutes.
<h3>Method of</h3>
<p><a href="ref_d-e.html#Date_object">Date</a>
<h3>Examples</h3>
<pre>
theBigDay.setMinutes(45)
</pre>
<h3>See also</h3>
<li><a href="ref_f-g.html#getMinutes_method">getMinutes</a> method
<!------------------------------------------------------------------------------------------------>
<hr>
<a name="setMonth_method"><h2>setMonth method</h2></a>
<p>
Sets the month for a specified date.
<h3>Syntax</h3>
<pre><i>dateObjectName</i>.setMonth(<i>monthValue</i>)</pre>
<p><i>dateObjectName</i> is either the name of a date object or a property of an existing object.
<br><i>monthValue</i> is an integer between 0 and 11 (representing the months January through December), or a property of an existing object.
<h3>Method of</h3>
<p><a href="ref_d-e.html#Date_object">Date</a>
<h3>Examples</h3>
<pre>
theBigDay.setMonth(6)
</pre>
<h3>See also</h3>
<li><a href="ref_f-g.html#getMonth_method">getMonth</a> method
<!------------------------------------------------------------------------------------------------>
<hr>
<a name="setSeconds_method"><h2>setSeconds method</h2></a>
<p>
Sets the seconds for a specified date.
<h3>Syntax</h3>
<pre><i>dateObjectName</i>.setSeconds(<i>secondsValue</i>)</pre>
<p><i>dateObjectName</i> is either the name of a date object or a property of an existing object.
<br><i>secondsValue</i> is an integer between 0 and 59 or a property of an existing object.
<h3>Method of</h3>
<p><a href="ref_d-e.html#Date_object">Date</a>
<h3>Examples</h3>
<pre>
theBigDay.setSeconds(30)
</pre>
<h3>See also</h3>
<li><a href="ref_f-g.html#getSeconds_method">getSeconds</a> method
<!---------------------------------------------------------------------------->
<hr>
<a name="setTime_method"><h2>setTime method</h2></a>
<p>
Sets the value of a date object.
<h3>Syntax</h3>
<p><pre><i>dateObjectName</i>.setTime(<i>timevalue</i>) </pre>
<p><i>dateObjectName</i> is either the name of a date object or a property of an existing object.
<br><i>timevalue</i> is an integer or a property of an existing object, representing the number of milliseconds since the epoch (1 January 1970 00:00:00).
<h3>Method of</h3>
<p><a href="ref_d-e.html#Date_object">Date</a>
<h3>Description</h3>
<p>
Use the setTime method to help assign a date and time to another date object.
<h3>Examples</h3>
<pre>
theBigDay = new Date("July 1, 1999")
sameAsBigDay = new Date()
sameAsBigDay.setTime(theBigDay.getTime())
</pre>
<h3>See also</h3>
<li><a href="ref_f-g.html#getTime_method">getTime</a> method
<!------------------------------------------------------------------------------------------------>
<hr>
<a name="setTimeout_method"><h2>setTimeout method</h2></a>
<p>Evaluates an expression after a specified number of milliseconds have elapsed.
<h3>Syntax</h3>
<pre><i>timeoutID</i>=setTimeout(<i>expression</i>, <i>msec</i>)</pre>
<p><i>timeoutID</i> is an identifier that is used only to cancel the evaluation with the clearTimeout method.
<br><i>expression</i> is a string expression or a property of an existing object.
<br><i>msec</i> is a numeric value, numeric string, or a property of an existing object in millisecond units.
<h3>Method 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 setTimeout method evaluates an expression after a specified amount of time. It does not evaluate the expression repeatedly. For example, if a setTimeout method specifies 5 seconds, the expression is evaluated after 5 seconds, not every 5 seconds.
<h3>Examples</h3>
<p><b>Example 1.</b> The following example displays an alert message 5 seconds (5,000 milliseconds) after the user clicks a button. If the user clicks the second button before the alert message is displayed, the timeout is canceled and the alert does not display.
<xmp>
<script language="JavaScript">
function displayAlert() {
alert("5 seconds have elapsed since the button was clicked.")
}
</script>
<body>
<form>
Click the button on the left for a reminder in 5 seconds;
click the button on the right to cancel the reminder before
it is displayed.
<p>
<input type="button" value="5-second reminder" name="remind_button" onclick="timerID=setTimeout('displayAlert()',5000)">
<input type="button" value="Clear the 5-second reminder" name="remind_disable_button" onclick="clearTimeout(timerID)">
</form>
</body>
</xmp>
<p><b>Example 2.</b> The following example displays the current time in a text object. The showtime() function, which is called recursively, uses the setTimeout method update the time every second.
<xmp>
<head>
<script language="JavaScript">
<!--
var timerID = null
var timerRunning = false
function stopclock(){
if(timerRunning)
clearTimeout(timerID)
timerRunning = false
}
function startclock(){
// Make sure the clock is stopped
stopclock()
showtime()
}
function showtime(){
var now = new Date()
var hours = now.getHours()
var minutes = now.getMinutes()
var seconds = now.getSeconds()
var timeValue = "" + ((hours > 12) ? hours - 12 : hours)
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
timeValue += (hours >= 12) ? " P.M." : " A.M."
document.clock.face.value = timeValue
timerID = setTimeout("showtime()",1000)
timerRunning = true
}
//-->
</script>
</head>
<body onload="startclock()">
<form name="clock" onsubmit="0">
<input type="text" name="face" size="12" value="">
</form>
</body>
</xmp>
<h3>See also</h3>
<li><a href="ref_a-c.html#clearTimeout_method">clearTimeout</a> method
<!------------------------------------------------------------------------------------------------>
<hr>
<a name="setYear_method"><h2>setYear method</h2></a>
<p>
Sets the year for a specified date.
<h3>Syntax</h3>
<pre><i>dateObjectName</i>.setYear(<i>yearValue</i>)</pre>
<p><i>dateObjectName</i> is either the name of a date object or a property of an existing object.
<br><i>yearValue</i> is an integer greater than 1900 or a property of an existing object.
<h3>Method of</h3>
<p><a href="ref_d-e.html#Date_object">Date</a>
<h3>Examples</h3>
<pre>
theBigDay.setYear(96)
</pre>
<h3>See also</h3>
<li><a href="ref_f-g.html#getYear_method">getYear</a> method
<!------------------------------------------------------------------------------------------------>
<hr>
<a name="sin_method"><h2>sin method</h2></a>
<p>
Returns the sine of a number.
<h3>Syntax</h3>
<pre>Math.sin(<i>number</i>)</pre>
<p><i>number</i> is a numeric expression or a property of an existing object, representing the size of an angle in radians.
<h3>Method of</h3>
<p><a href="ref_m-q.html#Math_object">Math</a>
<h3>Description</h3>
<p>The sin method returns a numeric value between -1 and 1, which represents the sine of the angle.
<h3>Examples</h3>
<pre>
//Displays the value 1
document.write("The sine of pi/2 radians is " +
Math.sin(Math.PI/2))
//Displays the value 1.224606353822377e-016
document.write("<P;>The; sine of pi radians is " +
Math.sin(Math.PI))
//Displays the value 0
document.write("<P;>The; sine of 0 radians is " +
Math.sin(0))
</pre>
<h3>See also</h3>
<li><a href="ref_a-c.html#acos_method">acos</a>, <a href="ref_a-c.html#asin_method">asin</a>, <a href="ref_a-c.html#atan_method">atan</a>, <a href="ref_a-c.html#cos_method">cos</a>, <a href="ref_t-z.html#tan_method">tan</a> methods
<!------------------------------------------------------------------------------------------------>
<hr>
<a name="small_method"><h2>small method</h2></a>
<p>
Causes a string to be displayed in a small font as if it were in a <SMALL;> tag.
<h3>Syntax</h3>
<pre><i>stringName</i>.small()</pre>
<p><i>stringName</i> is any string or a property of an existing object.
<h3>Method of</h3>
<p><a href="ref_s-s.html#string_object">string</a>
<h3>Description</h3>
<p>Use the small method with the write or writeln methods to format and display a string in a document.
<h3>Examples</h3>
The following example uses string methods to change the size of a string:
<pre>
var worldString="Hello, world"
document.write(worldString.small())
document.write("<P;>" + worldString.big())
document.write("<P;>" + worldString.fontsize(7))
</pre>
<p>The previous example produces the same output as the following HTML:
<pre>
<tt><SMALL;>Hello;, world</SMALL></tt>
<tt><P;><BIG;>Hello;, world</BIG></tt>
<tt><P;><FONTSIZE;=7>Hello;, world</FONTSIZE></tt>
</pre>
<h3>See also</h3>
<li><a href="ref_a-c.html#big_method">big</a>, <a href="ref_f-g.html#fontsize_method">fontsize</a> methods
<!------------------------------------------------------------------------------------------------>
<hr>
<a name="sqrt_method"><h2>sqrt method</h2></a>
<p>
Returns the square root of a number.
<h3>Syntax</h3>
<pre>Math.sqrt(<i>number</i>)</pre>
<i>number</i> is any non-negative 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>Description</h3>
<p>If the value of <i>number</i> is outside the suggested range, the return value is always 0.
<h3>Examples</h3>
<pre>
//Displays the value 3
document.write("The square root of 9 is " + Math.sqrt(9))
//Displays the value 1.414213562373095
document.write("<P;>The; square root of 2 is " + Math.sqrt(2))
//Displays the value 0 because the argument is out of range
document.write("<P;>The; square root of -1 is " + Math.sqrt(-1))
</pre>
<!------------------------------------------------------------------------------------------------>
<hr>
<a name="SQRT1_2_property"><h2>SQRT1_2 property</h2></a>
<p>
The square root of one-half; equivalently, one over the square root of two, approximately 0.707.
<h3>Syntax</h3>
<pre>Math.SQRT1_2</pre>
<h3>Property of</h3>
<p><a href="ref_m-q.html#Math_object">Math</a>
<h3>Description</h3>
<p>Because SQRT1_2 is a constant, it is a read-only property of Math.
<h3>Examples</h3>
<p>The following example displays 1 over the square root of 2:
<pre>document.write("1 over the square root of 2 is " + Math.SQRT1_2)</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_m-q.html#PI_property">PI</a>, <a href="ref_s-s.html#SQRT2_property">SQRT2</a> properties
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="SQRT2_property"><h2>SQRT2 property</h2></a>
<p>
The square root of two, approximately 1.414.
<h3>Syntax</h3>
<pre>Math.SQRT2</pre>
<h3>Property of</h3>
<p><a href="ref_m-q.html#Math_object">Math</a>
<h3>Description</h3>
<p>Because SQRT2 is a constant, it is a read-only property of Math.
<h3>Examples</h3>
<p>The following example displays the square root of 2:
<pre>document.write("The square root of 2 is " + Math.SQRT2)</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_m-q.html#PI_property">PI</a>, <a href="ref_s-s.html#SQRT1_2_property">SQRT1_2</a> properties
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="status_property"><h2>status property</h2></a>
<p>
Specifies a priority or transient message in the status bar at the bottom of the window, such as the message that appears when a mouseOver event occurs over an anchor.
<h3>Syntax</h3>
<pre><i>windowReference</i>.status</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>Do not confuse the status property with the defaultStatus property. The defaultStatus property reflects the default message displayed in the status bar.
<p>You can set the status property at any time. You must return true if you want to set the status property in the onMouseOver event handler.
<h3>Examples</h3>
<p>
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 an anchor to specify a value for the HREF attribute of the anchor dynamically, and the onMouseOver event handler to specify a custom message for the window in the status property:
<xmp><a href="" onclick="this.href=pickRandomURL()" onmouseover="self.status='Pick a random URL'; return true">
Go!</a></xmp>
<p>In the above example, the status property of the window is assigned to the window's self property, as <tt>self.status</tt>. As this example shows, you must return true to set the status property in the onMouseOver event handler.
<h3>See also</h3>
<li><a href="ref_d-e.html#defaultStatus_property">defaultStatus</a> property
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="strike_method"><h2>strike method</h2></a>
<p>
Causes a string to be displayed as struck out text as if it were in a <STRIKE;> tag.
<h3>Syntax</h3>
<pre><i>stringName</i>.strike()</pre>
<p><i>stringName</i> is any string or a property of an existing object.
<h3>Method of</h3>
<p><a href="ref_s-s.html#string_object">string</a>
<h3>Description</h3>
<p>Use the strike method with the write or writeln methods to format and display a string in a document.
<h3>Examples</h3>
The following example uses string methods to change the formatting of a string:
<pre>
var worldString="Hello, world"
document.write(worldString.blink())
document.write("<P;>" + worldString.bold())
document.write("<P;>" + worldString.italics())
document.write("<P;>" + worldString.strike())
</pre>
<p>The previous example produces the same output as the following HTML:
<pre>
<tt><BLINK;>Hello;, world</BLINK></tt>
<tt><P;><B;>Hello;, world</B></tt>
<tt><P;><I;>Hello;, world</I></tt>
<tt><P;><STRIKE;>Hello;, world</STRIKE></tt>
</pre>
<h3>See also</h3>
<li><a href="ref_a-c.html#blink_method">blink</a>, <a href="ref_a-c.html#bold_method">bold</a>, <a href="ref_h-l.html#italics_method">italics</a> methods
<!------------------------------------------------------------------------------------------------>
<hr>
<a name="string_object"><h2>string object</h2></a>
<p>A series of characters.
<h3>Syntax</h3>
<p>To use a string object:
<pre>
1. <i>stringName</i>.<i>propertyName</i>
2. <i>stringName</i>.<i>methodName</i>(<i>parameters</i>)
</pre>
<i>stringName</i> is the name of a string variable.
<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>None.
<h3>Description</h3>
<p>The string object is a built-in JavaScript object.
<p>A string can be represented as a literal enclosed by single or double quotes; for example, "Netscape" or 'Netscape'.
<h3>Properties</h3>
<li><a href="ref_h-l.html#length_property">length</a> reflects the length of the string
<h3>Methods</h3>
<li><a href="ref_a-c.html#anchor_method">anchor</a>
<li><a href="ref_a-c.html#big_method">big</a>
<li><a href="ref_a-c.html#blink_method">blink</a>
<li><a href="ref_a-c.html#bold_method">bold</a>
<li><a href="ref_a-c.html#charAt_method">charAt</a>
<li><a href="ref_f-g.html#fixed_method">fixed</a>
<li><a href="ref_f-g.html#fontcolor_method">fontcolor</a>
<li><a href="ref_f-g.html#fontsize_method">fontsize</a>
<li><a href="ref_h-l.html#indexOf_method">indexOf</a>
<li><a href="ref_h-l.html#italics_method">italics</a>
<li><a href="ref_h-l.html#lastIndexOf_method">lastIndexOf</a>
<li><a href="ref_h-l.html#link_method">link</a>
<li><a href="ref_s-s.html#small_method">small</a>
<li><a href="ref_s-s.html#strike_method">strike</a>
<li><a href="ref_s-s.html#sub_method">sub</a>
<li><a href="ref_s-s.html#substring_method">substring</a>
<li><a href="ref_s-s.html#sup_method">sup</a>
<li><a href="ref_t-z.html#toLowerCase_method">toLowerCase</a>
<li><a href="ref_t-z.html#toUpperCase_method">toUpperCase</a>
<h3>Event handlers</h3>
<li>None. Built-in objects do not have event handlers.
<h3>Examples</h3>
<p>The following statement creates a string variable.
<xmp>
var last_name = "Schaefer"
</xmp>
The following statements evaluate to 8, "SCHAEFER", and "schaefer":
<xmp>
last_name.length
last_name.toUpperCase()
last_name.toLowerCase()
</xmp>
<h3>See also</h3>
<li><a href="ref_t-z.html#text_object">text</a> and <a href="ref_t-z.html#textarea_object">textarea</a> objects
<!------------------------------------------------------------------------------------------------->
<hr>
<a name="sub_method"><h2>sub method</h2></a>
<p>
Causes a string to be displayed as a subscript as if it were in a <SUB;> tag.
<h3>Syntax</h3>
<pre><i>stringName</i>.sub()</pre>
<p><i>stringName</i> is any string or a property of an existing object.
<h3>Method of</h3>
<p><a href="ref_s-s.html#string_object">string</a>
<h3>Description</h3>
<p>Use the sub method with the write or writeln methods to format and display a string in a document.
<h3>Examples</h3>
The following example uses the sub and sup methods to format a string:
<pre>
var superText="superscript"
var subText="subscript"
document.write("This is what a " + superText.sup() + " looks like.")
document.write("<P;>This; is what a " + subText.sub() + " looks like.")
</pre>
<p>The previous example produces the same output as the following HTML:
<pre>
This is what a <SUP;>superscript;</SUP> looks like.
<P;>This; is what a <SUB;>subscript;</SUB> looks like.
</pre>
<h3>See also</h3>
<p><a href="ref_s-s.html#sup_method">sup</a> method
<!------------------------------------------------------------------------------------------------>
<hr>
<a name="submit_method"><h2>submit method</h2></a>
<p>