📄 ref_a-c.htm
字号:
document.form1.cityName.value = document.form1.cityName.value.toUpperCase()
}
</SCRIPT>
<BODY>
<FORM NAME="form1">
<B>Last name:</B>
<INPUT TYPE="text" NAME="lastName" SIZE=20 onChange="convertField(this)">
<BR><B>First name:</B>
<INPUT TYPE="text" NAME="firstName" SIZE=20 onChange="convertField(this)">
<BR><B>City:</B>
<INPUT TYPE="text" NAME="cityName" SIZE=20 onChange="convertField(this)">
<P><INPUT TYPE="checkBox" NAME="convertUpper"
onClick="if (this.checked) {convertAllFields()}"
> Convert fields to upper case
</FORM>
</BODY>
</htm>
</XMP>
<H3>See also</H3>
<LI><A HREF="ref_f-g.htm#form_object" form_object">form</A> and <A HREF="ref_r-r.htm#radio_object" radio_object">radio</A> objects
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="checked_property"><H2>checked property</H2></A>
<P>
A Boolean value specifying the selection state of a checkbox object or radio button.
<H3>语法</H3>
<PRE>
1. <I>checkboxName</I>.checked
2. <I>radioName</I>[<I>index</I>].checked
</PRE>
<P><I>checkboxName</I> is either the value of the NAME attribute of a checkbox object or an element in the <I>elements</I> array.
<BR><I>radioName</I> is the value of the NAME attribute of a radio object.
<BR><I>index</I> is an integer representing a radio button in a radio object.
<H3>Property of</H3>
<P><A HREF="ref_a-c.htm#checkbox_object" checkbox_object">checkbox</A>, <A HREF="ref_r-r.htm#radio_object" radio_object">radio</A>
<H3>描述</H3>
<P>If a checkbox or radio button is selected, the value of its checked property is true; otherwise, it is false.
<P>You can set the checked property at any time. The display of the checkbox or radio button updates immediately when you set the checked property.
<H3>例子</H3>
<P>The following example examines an array of radio buttons called <I>musicType</I> on the <I>musicForm</I> form to determine which button is selected. The VALUE attribute of the selected button is assigned to the <I>checkedButton</I> variable.
<PRE>
function stateChecker() {
var checkedButton = ""
for (var i in document.musicForm.musicType) {
if (document.musicForm.musicType[i].checked=="1") {
checkedButton=document.musicForm.musicType[i].value
}
}
}
</PRE>
<H3>See also</H3>
<LI><A HREF="ref_d-e.htm#defaultChecked_property" defaultChecked_property">defaultChecked</A> property
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="clear_method"><H2>clear method</H2></A>
<P>
Clears the document in a window.
<H3>语法</H3>
<PRE>document.clear()</PRE>
<H3>用法</H3>
<P><A HREF="ref_d-e.htm#document_object" document_object">document</A>
<H3>描述</H3>
<P>The clear method empties the content of a window, regardless of how the content of the window has been painted.
<H3>例子</H3>
<P>When the following function is called, the clear method empties the contents of the <I>msgWindow</I> window:
<PRE>
function windowCleaner() {
msgWindow.document.clear()
msgWindow.document.close()
}
</PRE>
<H3>See also</H3>
<LI><A HREF="ref_a-c.htm#close_document_method" close_document_method">close</A>, <A HREF="ref_m-q.htm#open_document_method" open_document_method">open</A>, <A HREF="ref_t-z.htm#write_method" write_method">write</A>, <A HREF="ref_t-z.htm#writeln_method" writeln_method">writeln</A> methods
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="clearTimeout_method"><H2>clearTimeout method</H2></A>
<P>Cancels a timeout that was set with the setTimeout method.
<H3>语法</H3>
<PRE>clearTimeout(<I>timeoutID</I>)</PRE>
<P><I>timeoutID</I> is a timeout setting that was returned by a previous call to the setTimeout method.
<H3>用法</H3>
<P><A HREF="ref_f-g.htm#frame_object" frame_object">frame</A>, <A HREF="ref_t-z.htm#window_object" window_object">window</A>
<H3>描述</H3>
<P>See the 描述 for the <A HREF="ref_s-s.htm#setTimeout_method" setTimeout_method">setTimeout</A> method.
<H3>例子</H3>
<P>See the 例子 for the <A HREF="ref_s-s.htm#setTimeout_method" setTimeout_method">setTimeout</A> method.
<H3>See also</H3>
<LI><A HREF="ref_s-s.htm#setTimeout_method" setTimeout_method">setTimeout</A> method
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="click_method"><H2>click method</H2></A>
<P>
Simulates a mouse click on the calling form element.
<H3>语法</H3>
<PRE>
1. <I>buttonName</I>.click()
2. <I>radioName</I>[<I>index</I>].click()
<BR>3. <I>checkboxName</I>.click()
</PRE>
<P><I>buttonName</I> is either the value of the NAME attribute of a button, reset, or submit object or an element in the <I>elements</I> array.
<BR><I>radioName</I> is the value of the NAME attribute of a radio object or an element in the <I>elements</I> array.
<BR><I>index</I> is an integer representing a radio button in a radio object.
<BR><I>checkboxName</I> is either the value of the NAME attribute of a checkbox object or an element in the <I>elements</I> array.
<H3>用法</H3>
<P><A HREF="ref_a-c.htm#button_object" button_object">button</A>, <A HREF="ref_a-c.htm#checkbox_object" checkbox_object">checkbox</A>, <A HREF="ref_r-r.htm#radio_object" radio_object">radio</A>, <A HREF="ref_r-r.htm#reset_object" reset_object">reset</A>, <A HREF="ref_s-s.htm#submit_object" submit_object">submit</A>
<H3>描述</H3>
<P>The effect of the click method varies according to the calling element:
<LI>For button, reset, and submit, performs the same action as clicking the button.
<LI>For a radio, selects a radio button.
<LI>For a checkbox, checks the checkbox and sets its value to on.
<H3>例子</H3>
<P>The following example toggles the selection status of the first radio button in the <I>musicType</I> radio object on the <I>musicForm</I> form:
<PRE>document.musicForm.musicType[0].click()</PRE>
<P>The following example toggles the selection status of the <I>newAge</I> checkbox on the <I>musicForm</I> form:
<PRE>document.musicForm.newAge.click()</PRE>
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="close_document_method"><H2>close method (document object)</H2></A>
<P>
Closes an output stream and forces data sent to layout to display.
<H3>语法</H3>
<PRE>document.close()</PRE>
<H3>用法</H3>
<P><A HREF="ref_d-e.htm#document_object" document_object">document</A>
<H3>描述</H3>
<P>The close method closes a stream opened with the document.open() method. If the stream was opened to layout, the close method forces the content of the stream to display. Font style tags, such as <BIG> and <CENTER>, automatically flush a layout stream.
<P>The close method also stops the "meteor shower" in the Netscape icon and displays "Document: Done" in the status bar.
<H3>例子</H3>
The following function calls document.close() to close a stream that was opened with document.open(). The document.close() method forces the content of the stream to display in the window.
<PRE>
function windowWriter1() {
var myString = "Hello, world!"
msgWindow.document.open()
msgWindow.document.write(myString + "<P>")
msgWindow.document.close()
}
</PRE>
<H3>See also</H3>
<LI><A HREF="ref_a-c.htm#clear_method" clear_method">clear</A>, <A HREF="ref_m-q.htm#open_document_method" open_document_method">open</A>, <A HREF="ref_t-z.htm#write_method" write_method">write</A>, <A HREF="ref_t-z.htm#writeln_method" writeln_method">writeln</A> methods
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="close_window_method"><H2>close method (window object)</H2></A>
<P>
Closes the specified window.
<H3>语法</H3>
<PRE><I>windowReference</I>.close()</PRE>
<P><I>windowReference</I> is a valid way of referring to a window, as described in the <A HREF="ref_t-z.htm#window_object" window_object">window</A> object.
<H3>用法</H3>
<P><A HREF="ref_t-z.htm#window_object" window_object">window</A>
<H3>描述</H3>
<P>The close method closes the specified window. If you call close without specifying a <I>windowReference</I>, JavaScript closes the current window.
<P>In event handlers, you must specify window.close() instead of simply using close(). Due to the scoping of static objects in JavaScript, a call to close() without specifying an object name is equivalent to document.close().
<H3>例子</H3>
<P>Any of the following 例子 close the current window:
<PRE>window.close()
self.close()
close()</PRE>
<P>The following example closes the <I>messageWin</I> window:
<PRE>messageWin.close()</PRE>
<P>This example assumes that the window was opened in a manner similar to the following:
<PRE>messageWin=window.open("")</PRE>
<H3>See also</H3>
<LI><A HREF="ref_m-q.htm#open_window_method" open_window_method">open</A> method
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="confirm_method"><H2>confirm method</H2></A>
<P>
Displays a Confirm dialog box with the specified message and OK and Cancel buttons.
<H3>语法</H3>
<P>confirm("<I>message</I>")
<P><I>message</I> is any string or a property of an existing object.
<H3>用法</H3>
<P><A HREF="ref_t-z.htm#window_object" window_object">window</A>
<H3>描述</H3>
<P>Use the confirm method to ask the user to make a decision that requires either an OK or a Cancel. The <I>message</I> argument specifies a message that prompts the user for the decision. The confirm method returns true if the user chooses OK and false if the user chooses Cancel.
<P>Although confirm is a 用法 the window object, you do not need to specify a <I>windowReference</I> when you call it. For example, <TT><I>windowReference</I>.confirm()</TT> is unnecessary.
<H3>例子</H3>
<P>This example uses the confirm method in the <I>confirmCleanUp()</I> function to confirm that the user of an application really wants to quit. If the user chooses OK, the custom <I>cleanUp()</I> function closes the application.
<PRE>
function confirmCleanUp() {
if (confirm("Are you sure you want to quit this application?")) {
cleanUp()
}
}</PRE>
You can call the <I>confirmCleanUp()</I> function in the onClick event handler of a form's pushbutton, as shown in the following example:
<PRE><INPUT TYPE="button" VALUE="Quit" onClick="confirmCleanUp()"></PRE>
<H3>See also</H3>
<LI><A HREF="ref_a-c.htm#alert_method" alert_method">alert</A>, <A HREF="ref_m-q.htm#prompt_method" prompt_method">prompt</A> methods
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="cookie_property"><H2>cookie property</H2></A>
<P>
String value of a cookie, which is a small piece of information stored by the Navigator in the cookies.txt file.
<H3>语法</H3>
<PRE>document.cookie</PRE>
<H3>Property of</H3>
<P><A HREF="ref_d-e.htm#document_object" document_object">document</A>
<H3>描述</H3>
<P>Use string methods such as substring, charAt, indexOf, and lastIndexOf to determine the value stored in the cookie. See the <A HREF="tppmsgs/msgs0.htm#4" tppabs="http://home.netscape.com/newsref/std/cookie_spec.htm" TARGET="_top">Netscape cookie specification</A> for a complete specification of the cookie 语法.
<P>You can set the cookie property at any time.
<H3>例子</H3>
<P>The following function uses the cookie property to record a reminder for users of
an application. The "expires=" component sets an expiration date for the cookie,
so it persists beyond the current browser session. The format of the date must be
<PRE>
Wdy, DD-Mon-YY HH:MM:SS GMT
</PRE>
where Wdy is the full name of the day of the week, DD is an integer representation
of the day of the month, Mon is the month, YY is the last two digits of the year,
and HH, MM, and SS are two-digit representations of hours, minutes, and seconds,
respectively.
<P>
This is the same date format as returned by <i>Date.toGMTString</i>,
except:
<UL>
<LI>Dashes are added between the day, month, and year
<LI>Year is two-digit for cookies.
</UL>
<P>
For example, a valid cookie expiration date is:
<BR>
expires=Wednesday, 09-Nov-99 23:12:40 GMT
<PRE>
function RecordReminder(time, expression) {
// Record a cookie of the form "@<T>=<E>" to map
// from <T> in milliseconds since the epoch,
// returned by Date.getTime(), onto an encoded expression,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -