📄 ref_f-g.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="fgColor_property"><H2>fgColor property</H2></A>
<P>
A string specifying the color of the document text.
<H3>语法</H3>
<PRE>document.fgColor</PRE>
<H3>Property of</H3>
<P><A HREF="ref_d-e.htm#document_object" document_object">document</A>
<H3>描述</H3>
<P>The fgColor property is expressed as a hexadecimal RGB triplet 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>. This property is the JavaScript reflection of the TEXT attribute of the <BODY> tag. The default value of this property is set by the user on the Colors tab of the Preferences dialog box, which is displayed by choosing General Preferences from the Options menu. You cannot set this property after the htm source has been through layout.
<P>If you express the color as a hexadecimal RGB triplet, you must use the format rrggbb. For example, the hexadecimal RGB values for salmon are red=FA, green=80, and blue=72, so the RGB triplet for salmon is "FA8072".
<P>You can override the value set in the fgColor property in either of the following ways:
<LI>Setting the COLOR attribute of the <FONT> tag.
<LI>Using the fontcolor method.
<H3>例子</H3>
<P>The following example sets the color of the foreground text to aqua using a string literal:
<PRE>
document.fgColor="aqua"
</PRE>
<P>The following example sets the color of the foreground text to aqua using a hexadecimal triplet:
<PRE>
document.fgColor="00FFFF"
</PRE>
<H3>相关</H3>
<LI><A HREF="ref_a-c.htm#alinkColor_property" alinkColor_property">alinkColor</A>, <A HREF="ref_a-c.htm#bgColor_property" bgColor_property">bgColor</A>, <A HREF="ref_h-l.htm#linkColor_property" linkColor_property">linkColor</A>, and <A HREF="ref_t-z.htm#vlinkColor_property" vlinkColor_property">vlinkColor</A> properties
<LI><A HREF="ref_f-g.htm#fontcolor_method" fontcolor_method">fontcolor</A>
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="fixed_method"><H2>fixed method</H2></A>
<P>
Causes a string to be displayed in fixed-pitch font as if it were in a <TT> tag.
<H3>语法</H3>
<PRE><I>stringName</I>.fixed()</PRE>
<P><I>stringName</I> is any string or a property of an existing object.
<H3>方法</H3>
<P><A HREF="ref_s-s.htm#string_object" string_object">string</A>
<H3>描述</H3>
<P>Use the fixed method with the write or writeln methods to format and display a string in a document.
<H3>例子</H3>
The following example uses the fixed method to change the formatting of a string:
<PRE>
var worldString="Hello, world"
document.write(worldString.fixed())
</PRE>
<P>The previous example produces the same output as the following htm:
<PRE>
<TT><TT>Hello, world</TT></TT>
</PRE>
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="floor_method"><H2>floor method</H2></A>
<P>
Returns the greatest integer less than or equal to a number.
<H3>语法</H3>
<PRE>Math.floor(<I>number</I>)</PRE>
<P><I>number</I> is any numeric expression or a property of an existing object.
<H3>方法</H3>
<P><A HREF="ref_m-q.htm#Math_object" Math_object">Math</A>
<H3>例子</H3>
<PRE>
//Displays the value 45
document.write("<P>The floor of 45.95 is " + Math.floor(45.95))
//Displays the value -46
document.write("<P>The floor of -45.95 is " + Math.floor(-45.95))
</PRE>
<H3>相关</H3>
<LI><A HREF="ref_a-c.htm#ceil_method" ceil_method">ceil</A> method
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="focus_method"><H2>focus method</H2></A>
<P>
Gives focus to the specified object.
<H3>语法</H3>
<PRE>
1. <I>passwordName</I>.focus()
2. <I>selectName</I>.focus()
3. <I>textName</I>.focus()
4. <I>textareaName</I>.focus()
</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>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>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>方法</H3>
<P><A HREF="ref_m-q.htm#password_object" password_object">password</A>, <A HREF="ref_s-s.htm#select_object" select_object">select</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>Use the focus method to navigate to a specific form element and give it focus. You can then either programatically enter a value in the element or let the user enter a value.
<H3>例子</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 focus method returns focus to the password object and the select method highlights 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>相关</H3>
<LI><A HREF="ref_a-c.htm#blur_method" blur_method">blur</A>, <A HREF="ref_s-s.htm#select_method" select_method">select</A> methods
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="fontcolor_method"><H2>fontcolor method</H2></A>
<P>
Causes a string to be displayed in the specified color as if it were in a <FONT COLOR=<I>color</I>> tag.
<H3>语法</H3>
<PRE><I>stringName</I>.fontcolor(<I>color</I>)</PRE>
<P><I>stringName</I> is any string or a property of an existing object.
<BR><I>color</I> is a string or a property of an existing object, expressing the color as a hexadecimal RGB triplet 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>.
<H3>方法</H3>
<P><A HREF="ref_s-s.htm#string_object" string_object">string</A>
<H3>描述</H3>
<P>Use the fontcolor method with the write or writeln methods to format and display a string in a document.
<P>If you express <I>color</I> as a hexadecimal RGB triplet, you must use the format rrggbb. For example, the hexadecimal RGB values for salmon are red=FA, green=80, and blue=72, so the RGB triplet for salmon is "FA8072".
<P>The fontcolor method overrides a value set in the fgColor property.
<H3>例子</H3>
The following example uses the fontcolor method to change the color of a string
<PRE>
var worldString="Hello, world"
document.write(worldString.fontcolor("maroon") +
" is maroon in this line")
document.write("<P>" + worldString.fontcolor("salmon") +
" is salmon in this line")
document.write("<P>" + worldString.fontcolor("red") +
" is red in this line")
document.write("<P>" + worldString.fontcolor("8000") +
" is maroon in hexadecimal in this line")
document.write("<P>" + worldString.fontcolor("FA8072") +
" is salmon in hexadecimal in this line")
document.write("<P>" + worldString.fontcolor("FF00") +
" is red in hexadecimal in this line")
</PRE>
<P>The previous example produces the same output as the following htm:
<PRE>
<TT><FONT COLOR="maroon">Hello, world</FONT> is maroon in this line</TT>
<TT><P><FONT COLOR="salmon">Hello, world</FONT> is salmon in this line</TT>
<TT><P><FONT COLOR="red">Hello, world</FONT> is red in this line</TT>
<TT><FONT COLOR="8000">Hello, world</FONT> is maroon in hexadecimal in this line</TT>
<TT><P><FONT COLOR="FA8072">Hello, world</FONT> is salmon in hexadecimal in this line</TT>
<TT><P><FONT COLOR="FF00">Hello, world</FONT> is red in hexadecimal in this line</TT>
</PRE>
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="fontsize_method"><H2>fontsize method</H2></A>
<P>
Causes a string to be displayed in the specified font size as if it were in a <FONTSIZE=<I>size</I>> tag.
<H3>语法</H3>
<PRE><I>stringName</I>.fontsize(<I>size</I>)</PRE>
<P><I>stringName</I> is any string or a property of an existing object.
<BR><I>size</I> is an integer between one and seven, or a string representing a signed integer between 1 and 7, or a property of an existing object.
<H3>方法</H3>
<P><A HREF="ref_s-s.htm#string_object" string_object">string</A>
<H3>描述</H3>
<P>Use the fontsize method with the write or writeln methods to format and display a string in a document. When you specify <I>size</I> as an integer, you set the size of <I>stringName</I> to one of the seven defined sizes. When you specify <I>size</I> as a string such as "-2", you adjust the font size of <I>stringName</I> relative to the size set in the <BASEFONT> tag.
<H3>例子</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 htm:
<PRE>
<TT><SMALL>Hello, world</SMALL></TT>
<TT><P><BIG>Hello, world</BIG></TT>
<TT><P><FONTSIZE=7>Hello, world</FONTSIZE></TT>
</PRE>
<H3>相关</H3>
<LI><A HREF="ref_a-c.htm#big_method" big_method">big</A>, <A HREF="ref_s-s.htm#small_method" small_method">small</A> methods
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="form_object"><H2>form object (<I>forms</I> array)</H2> </A>
<P>Lets users input text and make choices from form objects such as checkboxes, radio buttons, and selection lists. You can also use a form to post data to a server.
<H3>语法</H3>
<P>To define a form, use standard htm 语法 with the addition of the onSubmit event handler:
<PRE>
<FORM
NAME="<I>formName</I>"
TARGET="<I>windowName</I>"
ACTION="<I>serverURL</I>"
METHOD=GET | POST
ENCTYPE="<I>encodingType</I>"
[onSubmit="<I>handlerText</I>"]>
</FORM>
</PRE>
<P><I>NAME="formName"</I> specifies the name of the form object.
<P><I>TARGET="windowName"</I> specifies the window that form responses go to. When you submit a form with a TARGET attribute, server responses are displayed in the specified window instead of the window that contains the form. <I>windowName</I> can be an existing window; it can be a frame name specified in a <FRAMESET> tag; or it can be one of the literal frame names _top, _parent, _self, or _blank; it cannot be a JavaScript expression (for example, it cannot be parent<I>.frameName</I> or <I>windowName.frameName</I>). Some values for this attribute may require specific values for other attributes. See <A HREF="tppmsgs/msgs0.htm#3" tppabs="http://www.ics.uci.edu/pub/ietf/htm/rfc1867.txt" TARGET="_top">RFC 1867</A> for details. You can access this value using the target property.
<P><I>ACTION="serverURL"</I> specifies the URL of the server to which form field input information is sent. This attribute can specify a CGI or LiveWire application on the server; it can also be a mailto: URL if the form is to be mailed. See the <A HREF="ref_h-l.htm#location_object" location_object">location</A> object for a 描述 of the URL components. Some values for this attribute may require specific values for other attributes. See <A HREF="tppmsgs/msgs0.htm#3" tppabs="http://www.ics.uci.edu/pub/ietf/htm/rfc1867.txt" TARGET="_top">RFC 1867</A> for details. You can access this value using the action property.
<P><I>METHOD=GET | POST</I> specifies how information is sent to the server specified by <I>ACTION</I>. GET (the default) appends the input information to the URL which on most receiving systems becomes the value of the environment variable <I>QUERY_STRING</I>. POST sends the input information in a data body which is available on <I>stdin</I> with the data length set in the environment variable <I>CONTENT_LENGTH</I>. Some values for this attribute may require specific values for other attributes. See <A HREF="tppmsgs/msgs0.htm#3" tppabs="http://www.ics.uci.edu/pub/ietf/htm/rfc1867.txt" TARGET="_top">RFC 1867</A> for details. You can access this value using the method property.
<P><I>ENCTYPE="encodingType"</I> specifies the MIME encoding of the data sent: "application/x-www-form-urlencoded" (the default) or "multipart/form-data". Some values for this attribute may require specific values for other attributes. See <A HREF="tppmsgs/msgs0.htm#3" tppabs="http://www.ics.uci.edu/pub/ietf/htm/rfc1867.txt" TARGET="_top">RFC 1867</A> for details. You can access this value using the encoding property.
<P>To use a form object's properties and methods:
<PRE>
1. <I>formName</I>.<I>propertyName</I>
2. <I>formName</I>.<I>methodName</I>(<I>parameters</I>)
3. forms[<I>index</I>].<I>propertyName</I>
4. forms[<I>index</I>].<I>methodName</I>(<I>parameters</I>)
</PRE>
<I>formName</I> is the value of the NAME attribute of a form object.
<BR><I>propertyName</I> is one of the properties listed below.
<BR><I>methodName</I> is one of the methods listed below.
<BR><I>index</I> is an integer representing a form object.
<H3>Property of</H3>
<LI><A HREF="ref_d-e.htm#document_object" document_object">document</A>
<H3>描述</H3>
<P>Each form in a document is a distinct object.
<P>You can reference a form's elements in your code by using the element's name (from the NAME attribute) or the <A HREF="ref_d-e.htm#elements_object" elements_object"><I>elements</I></A> array. The <I>elements</I> array contains an entry for each element (such as a checkbox, radio, or text object) in a form.
<H4>The <I>forms</I> array</H4>
<P>You can reference the forms in your code by using the <I>forms</I> array (you can also use the form name). This array contains an entry for each form object (<FORM> tag) in a document in source order. For example, if a document contains three forms, these forms are reflected as <TT>document.forms[0]</TT>, <TT>document.forms[1]</TT>, and <TT>document.forms[2]</TT>.
<P>To use the <I>forms</I> array:
<PRE>
1. document.forms[<I>index</I>]
2. document.forms.length
</PRE>
<P><I>index</I> is an integer representing a form in a document.
<P>To obtain the number of forms in a document, use the length property: <TT>document.forms.length</TT>.
<P>You can also refer to a form's elements by using the <I>forms</I> array. For example, you would refer to a text object named <I>quantity</I> in the second form as <TT>document.forms[1].quantity</TT>. You would refer to the value property of this text object as <TT>document.forms[1].quantity.value</TT>.
<P>Elements in the <I>forms</I> array are read-only. For example, the statement <TT>document.forms[0]="music"</TT> has no effect.
<P>The value of each element in the <I>forms</I> array is <TT><object <I>nameAttribute</I>></TT>, where <I>nameAttribute</I> is the NAME attribute of the form.
<H3>Properties</H3>
<P>The form object has the following properties:
<LI><A HREF="ref_a-c.htm#action_property" action_property">action</A> reflects the ACTION attribute
<LI><A HREF="ref_d-e.htm#elements_object" elements_object">elements</A> is an array reflecting all the elements in a form
<LI><A HREF="ref_d-e.htm#encoding_property" encoding_property">encoding</A> reflects the ENCTYPE attribute
<LI><A HREF="ref_h-l.htm#length_property" length_property">length</A> reflects the number of elements on a form
<LI><A HREF="ref_m-q.htm#method_property" method_property">method</A> reflects the METHOD attribute
<LI><A HREF="ref_t-z.htm#target_property" target_property">target</A> reflects the TARGET attribute
<P>The following objects are also properties of the form object:
<LI><A HREF="ref_a-c.htm#button_object" button_object">button</A>
<LI><A HREF="ref_a-c.htm#checkbox_object" checkbox_object">checkbox</A>
<LI><A HREF="ref_h-l.htm#hidden_object" hidden_object">hidden</A>
<LI><A HREF="ref_m-q.htm#password_object" password_object">password</A>
<LI><A HREF="ref_r-r.htm#radio_object" radio_object">radio</A>
<LI><A HREF="ref_r-r.htm#reset_object" reset_object">reset</A>
<LI><A HREF="ref_s-s.htm#select_object" select_object">select</A>
<LI><A HREF="ref_s-s.htm#submit_object" submit_object">submit</A>
<LI><A HREF="ref_t-z.htm#text_object" text_object">text</A>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -