?? ref_d-e.htm
字號:
<htm><title>網絡時空——網頁制作</title>
<link rel="shortcut icon" href="../../../../ccisn.ico">
<link href="../../../../common.css" type="text/css" rel="stylesheet"><style type="text/css">
<!--
td,p,div {font-size:9pt;font-family:宋體;}
BODY { font-family:宋體; margin-left:0; margin-top:0; font-size:9pt; background-color:#ffffff;}
A { font-size: 9pt;color:#0000aa; text-decoration:underline;font-family:宋體; }
A:hover,A:active{ color:#FF8019; text-decoration:underline;}
A.top{color:#ffffff;font-size:9pt}
-->
</style>
<body bgcolor="#ffffff" text="#000000" link="#003399" alink="#ff9900" vlink="#000000" background="../../../images/b01.jpg">
<A NAME="Date_object"><H2>Date object</H2></A>
<P>Lets you work with dates and times.
<H3>語法</H3>
<P>To create a Date object:
<PRE>
1. <I>dateObjectName</I> = new Date()
2. <I>dateObjectName</I> = new Date("<I>month day</I>, <I>year hours</I>:<I>minutes</I>:<I>seconds</I>")
3. <I>dateObjectName</I> = new Date(<I>year</I>, <I>month</I>, <I>day</I>)
4. <I>dateObjectName</I> = new Date(<I>year</I>, <I>month</I>, <I>day</I>, <I>hours</I>, <I>minutes</I>, <I>seconds</I>)
</PRE>
<I>dateObjectName</I> is either the name of a new object or a property of an existing object.
<BR><I>month, day, year, hours, minutes, and seconds</I> are string values for form 2 of the 語法. For forms 3 and 4, they are integer values.
<P>To use Date methods:
<PRE>
<I>dateObjectName.methodName(parameters)</I>
</PRE>
<I>dateObjectName</I> is either the name of an existing Date object or a property of an existing object..
<BR><I>methodName</I> is one of the methods listed below.
<P>Exceptions: The Date object's parse and UTC methods are static methods that you use as follows:
<PRE>
Date.UTC(<I>parameters</I>)
Date.parse(<I>parameters</I>)
</PRE>
<H3>Property of</H3>
<LI>None.
<H3>描述</H3>
<P>The Date object is a built-in JavaScript object.
<P>Form 1 of the 語法 creates today's date and time. If you omit hours, minutes, or seconds from form 2 or 4 of the 語法, the value will be set to zero.
<P>The way JavaScript handles dates is very similar to the way Java handles dates: both languages have many of the same date methods, and both store dates internally as the number of milliseconds since January 1, 1970 00:00:00. Dates prior to 1970 are not allowed.
<H3>Properties</H3>
<LI>None.
<H3>Methods</H3>
<LI><A HREF="ref_f-g.htm#getDate_method" getDate_method">getDate</A>
<LI><A HREF="ref_f-g.htm#getDay_method" getDay_method">getDay</A>
<LI><A HREF="ref_f-g.htm#getHours_method" getHours_method">getHours</A>
<LI><A HREF="ref_f-g.htm#getMinutes_method" getMinutes_method">getMinutes</A>
<LI><A HREF="ref_f-g.htm#getMonth_method" getMonth_method">getMonth</A>
<LI><A HREF="ref_f-g.htm#getSeconds_method" getSeconds_method">getSeconds</A>
<LI><A HREF="ref_f-g.htm#getTime_method" getTime_method">getTime</A>
<LI><A HREF="ref_f-g.htm#getTimezoneOffset_method" getTimezoneOffset_method">getTimezoneOffset</A>
<LI><A HREF="ref_f-g.htm#getYear_method" getYear_method">getYear</A>
<LI><A HREF="ref_m-q.htm#parse_method" parse_method">parse</A>
<LI><A HREF="ref_s-s.htm#setDate_method" setDate_method">setDate</A>
<LI><A HREF="ref_s-s.htm#setHours_method" setHours_method">setHours</A>
<LI><A HREF="ref_s-s.htm#setMinutes_method" setMinutes_method">setMinutes</A>
<LI><A HREF="ref_s-s.htm#setMonth_method" setMonth_method">setMonth</A>
<LI><A HREF="ref_s-s.htm#setSeconds_method" setSeconds_method">setSeconds</A>
<LI><A HREF="ref_s-s.htm#setTime_method" setTime_method">setTime</A>
<LI><A HREF="ref_s-s.htm#setYear_method" setYear_method">setYear</A>
<LI><A HREF="ref_t-z.htm#toGMTString_method" toGMTString_method">toGMTString</A>
<LI><A HREF="ref_t-z.htm#toLocaleString_method" toLocaleString_method">toLocaleString</A>
<LI><A HREF="ref_t-z.htm#UTC_method" UTC_method">UTC</A>
<H3>Event handlers</H3>
<LI>None. Built-in objects do not have event handlers.
<H3>例子</H3>
<P>
<XMP>today = new Date()
birthday = new Date("December 17, 1995 03:24:00")
birthday = new Date(95,12,17)
birthday = new Date(95,12,17,3,24,0)
</XMP>
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="defaultChecked_property"><H2>defaultChecked property</H2></A>
<P>
A Boolean value indicating the default selection state of a checkbox or radio button.
<H3>語法</H3>
<PRE>
1. <I>checkboxName</I>.defaultChecked
2. <I>radioName</I>[<I>index</I>].defaultChecked
</PRE>
<P><I>checkboxName</I> is either the value of the NAME attribute of a checkbox object or an element in the <I>elements</I> array.
<BR><I>radioName</I> is the value of the NAME attribute of a radio object.
<BR><I>index</I> is an integer representing a radio button in a radio object.
<H3>Property of</H3>
<P><A HREF="ref_a-c.htm#checkbox_object" checkbox_object">checkbox</A>, <A HREF="ref_r-r.htm#radio_object" radio_object">radio</A>
<H3>描述</H3>
<P>If an checkbox or radio button is selected by default, the value of the defaultChecked property is true; otherwise, it is false. defaultChecked initially reflects whether the CHECKED attribute is used within an <INPUT> tag; however, setting defaultChecked overrides the CHECKED attribute.
<P>You can set the defaultChecked property at any time. The display of the checkbox or radio button does not update when you set the defaultChecked property, only when you set the checked property.
<H3>例子</H3>
<P>The following example resets an array of radio buttons called <I>musicType</I> on the <I>musicForm</I> form to the default selection state.
<PRE>
function radioResetter() {
var i=""
for (i in document.musicForm.musicType) {
if (document.musicForm.musicType[i].defaultChecked==true) {
document.musicForm.musicType[i].checked=true
}
}
}
</PRE>
<H3>See also</H3>
<LI><A HREF="ref_a-c.htm#checked_property" checked_property">checked</A> property
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="defaultSelected_property"><H2>defaultSelected property</H2></A>
<P>
A Boolean value indicating the default selection state of an option in a select object.
<H3>語法</H3>
<PRE><I>selectName</I>.options[<I>index</I>].defaultSelected</PRE>
<P><I>selectName</I> is either the value of the NAME attribute of a select object or an element in the <I>elements</I> array.
<BR><I>index</I> is an integer representing an option in a select object.
<H3>Property of</H3>
<P><A HREF="ref_s-s.htm#select_object" select_object">options</A> array
<H3>描述</H3>
<P>If an option in a select object is selected by default, the value of the defaultSelected property is true; otherwise, it is false. defaultSelected initially reflects whether the SELECTED attribute is used within an <OPTION> tag; however, setting defaultSelected overrides the SELECTED attribute.
<P>You can set the defaultSelected property at any time. The display of the select object does not update when you set the defaultSelected property, only when you set the selected or selectedIndex properties.
<P>A select object created without the MULTIPLE attribute can have only one option selected by default. When you set defaultSelected in such an object, any previous default selections, including defaults set with the SELECTED attribute, are cleared. If you set defaultSelected in a select object created with the MULTIPLE attribute, previous default selections are not affected.
<H3>例子</H3>
<P>In the following example, the <I>restoreDefault()</I> function returns the <I>musicType</I> select object to its default state. The <B>for</B> loop uses the options array to evaluate every option in the select object. The <B>if</B> statement sets the selected property if defaultSelected is true.
<PRE>
function restoreDefault() {
for (var i = 0; i < document.musicForm.musicType.length; i++) {
if (document.musicForm.musicType.options[i].defaultSelected == true) {
document.musicForm.musicType.options[i].selected=true
}
}
}
</PRE>
The previous example assumes that the select object is similar to the following:
<PRE>
<SELECT NAME="musicType">
<OPTION SELECTED> R&B
<OPTION> Jazz
<OPTION> Blues
<OPTION> New Age
</SELECT>
</PRE>
<H3>See also</H3>
<LI><A HREF="ref_h-l.htm#index_property" index_property">index</A>, <A HREF="ref_s-s.htm#selected_property" selected_property">selected</A>, <A HREF="ref_s-s.htm#selectedIndex_property" selectedIndex_property">selectedIndex</A> properties
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="defaultStatus_property"><H2>defaultStatus property</H2></A>
<P>
The default message displayed in the status bar at the bottom of the window.
<H3>語法</H3>
<PRE><I>windowReference</I>.defaultStatus</PRE>
<P><I>windowReference</I> is a valid way of referring to a window, as described in the <A HREF="ref_t-z.htm#window_object" window_object">window</A> object.
<H3>Property of</H3>
<P><A HREF="ref_t-z.htm#window_object" window_object">window</A>
<H3>描述</H3>
<P>The defaultStatus message appears when nothing else is in the status bar. Do not confuse the defaultStatus property with the status property. The status property reflects a priority or transient message in the status bar, such as the message that appears when a mouseOver event occurs over an anchor.
<P>You can set the defaultStatus property at any time. You must return true if you want to set the defaultStatus property in the onMouseOver event handler.
<H3>例子</H3>
<P>In the following example, the <I>statusSetter()</I> function sets both the status and defaultStatus properties in an onMouseOver event handler:
<PRE>
function statusSetter() {
window.defaultStatus = "Click the link for the Netscape home page"
window.status = "Netscape home page"
}
<A HREF="http://www.netscape.com"
onMouseOver = "statusSetter(); return true">Netscape</A>
</PRE>
In the previous example, notice that the onMouseOver event handler returns a value of true. You must return true to set status or defaultStatus in an event handler.
<H3>See also</H3>
<LI><A HREF="ref_s-s.htm#status_property" status_property">status</A> property
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="defaultValue_property"><H2>defaultValue property</H2></A>
<P>
A string indicating the default value of a password, text, or textarea object.
<H3>語法</H3>
<PRE>
1. <I>passwordName</I>.defaultValue
2. <I>textName</I>.defaultValue
3. <I>textareaName</I>.defaultValue
</PRE>
<P><I>passwordName</I> is either the value of the NAME attribute of a password object or an element in the <I>elements</I> array.
<BR><I>textName</I> is either the value of the NAME attribute of a text object or an element in the <I>elements</I> array.
<BR><I>textareaName</I> is either the value of the NAME attribute of a textarea object or an element in the <I>elements</I> array.
<H3>Property of</H3>
<P><A HREF="ref_m-q.htm#password_object" password_object">password</A>, <A HREF="ref_t-z.htm#text_object" text_object">text</A>, <A HREF="ref_t-z.htm#textarea_object" textarea_object">textarea</A>
<H3>描述</H3>
<P>The initial value of defaultValue differs for each object:
<LI>For text objects, it initially reflects the value of the VALUE attribute.
<LI>For textarea objects, it initially reflects the value specified between the <TEXTAREA> and </TEXTAREA> tags.
<LI>For password objects, it initially is null (for security reasons), regardless of the value of the VALUE attribute.
<P>Setting defaultValue programatically overrides the initial setting. If you programatically set defaultValue for the password object and then evaluate it, JavaScript returns the current value.
<P>You can set the defaultValue property at any time. The display of the related object does not update when you set the defaultValue property, only when you set the value property.
<H3>例子</H3>
<P>The following function evaluates the defaultValue property of objects on the <I>surfCity</I> form and displays the values in the <I>msgWindow</I> window:
<PRE>
function defaultGetter() {
msgWindow=window.open("")
msgWindow.document.write("hidden.defaultValue is " +
document.surfCity.hiddenObj.defaultValue + "<BR>")
msgWindow.document.write("password.defaultValue is " +
document.surfCity.passwordObj.defaultValue + "<BR>")
msgWindow.document.write("text.defaultValue is " +
document.surfCity.textObj.defaultValue + "<BR>")
msgWindow.document.write("textarea.defaultValue is " +
document.surfCity.textareaObj.defaultValue + "<BR>")
msgWindow.document.close()
}
</PRE>
<H3>See also</H3>
<LI><A HREF="ref_t-z.htm#value_property" value_property">value</A> property
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="document_object"><H2>document object</H2> </A>
<P>Contains information on the current document, and provides methods for displaying htm output to the user.
<H3>語法</H3>
<P>To define a document object, use standard htm 語法:
<PRE>
<BODY
BACKGROUND="<I>backgroundImage</I>"
BGCOLOR="<I>backgroundColor</I>"
TEXT="<I>foregroundColor</I>"
LINK="<I>unfollowedLinkColor</I>"
ALINK="<I>activatedLinkColor</I>"
VLINK="<I>followedLinkColor</I>"
[onLoad="<I>handlerText</I>"]
[onUnload="<I>handlerText</I>"]>
</BODY>
</PRE>
<I>BACKGROUND</I> specifies an image that fills the background of the document.
<BR><I>BGCOLOR</I>, <I>TEXT</I>, <I>LINK</I>, <I>ALINK</I>, and <I>VLINK</I> are color specifications expressed as a hexadecimal RGB triplet (in the format "rrggbb" or "#rrggbb") or as one of the string literals listed in <A HREF="tppmsgs/msgs0.htm#11" tppabs="http://www.nease.net/~jim/colors.htm">Color Values</A>.
<P>To use a document object's properties and methods:
<PRE>
1. document.<I>propertyName</I>
2. document.<I>methodName</I>(<I>parameters</I>)
</PRE>
<I>propertyName</I> is one of the properties listed below.
<BR><I>methodName</I> is one of the methods listed below.
<H3>Property of</H3>
<LI><A HREF="ref_t-z.htm#window_object" window_object">window</A>
<H3>描述</H3>
<P>An htm document consists of a <HEAD> and <BODY> tag. The <HEAD> includes information on the document's title and base (the absolute URL base to be used for relative URL links in the document). The <BODY> tag encloses the body of a document, which is defined by the current URL. The entire body of the document (all other htm elements for the document) goes within the <BODY> tag.
<P>You can load a new document by using the <A HREF="ref_h-l.htm#location_object" location_object">location</A> object.
<P>You can reference the anchors, forms, and links of a document by using the <I>anchors, forms,</I> and <I>links</I> arrays. These arrays contain an entry for each anchor, form, or link in a document.
<H3>Properties</H3>
<LI><A HREF="ref_a-c.htm#alinkColor_property" alinkColor_property">alinkColor</A> reflects the ALINK attribute
<LI><A HREF="ref_a-c.htm#anchor_object" anchor_object">anchors</A> is an array reflecting all the anchors in a document
<LI><A HREF="ref_a-c.htm#bgColor_property" bgColor_property">bgColor</A> reflects the BGCOLOR attribute
<LI><A HREF="ref_a-c.htm#cookie_property" cookie_property">cookie</A> specifies a cookie
<LI><A HREF="ref_f-g.htm#fgColor_property" fgColor_property">fgColor</A> reflects the TEXT attribute
<LI><A HREF="ref_f-g.htm#form_object" form_object">forms</A> is an array reflecting all the forms in a document
<LI><A HREF="ref_h-l.htm#lastModified_property" lastModified_property">lastModified</A> reflects the date a document was last modified
<LI><A HREF="ref_h-l.htm#linkColor_property" linkColor_property">linkColor</A> reflects the LINK attribute
<LI><A HREF="ref_h-l.htm#link_object" link_object">links</A> is an array reflecting all the links in a document
<LI><A HREF="ref_h-l.htm#location_property" location_property">location</A> reflects the complete URL of a document
<LI><A HREF="ref_r-r.htm#referrer_property" referrer_property">referrer</A> reflects the URL of the calling document
<LI><A HREF="ref_t-z.htm#title_property" title_property">title</A> reflects the contents of the <TITLE> tag
<LI><A HREF="ref_t-z.htm#vlinkColor_property" vlinkColor_property">vlinkColor</A> reflects the VLINK attribute
<P>The following objects are also properties of the document object:
<LI><A HREF="ref_a-c.htm#anchor_object" anchor_object">anchor</A>
<LI><A HREF="ref_f-g.htm#form_object" form_object">form</A>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -