📄 ref_f-g.htm
字号:
<htm>
<BODY>
<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" tppabs="http://www.nease.net/~jim/ref_d-e.htm#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" tppabs="http://www.nease.net/~jim/ref_a-c.htm#alinkColor_property">alinkColor</A>, <A HREF="ref_a-c.htm#bgColor_property" tppabs="http://www.nease.net/~jim/ref_a-c.htm#bgColor_property">bgColor</A>, <A HREF="ref_h-l.htm#linkColor_property" tppabs="http://www.nease.net/~jim/ref_h-l.htm#linkColor_property">linkColor</A>, and <A HREF="ref_t-z.htm#vlinkColor_property" tppabs="http://www.nease.net/~jim/ref_t-z.htm#vlinkColor_property">vlinkColor</A> properties
<LI><A HREF="ref_f-g.htm#fontcolor_method" tppabs="http://www.nease.net/~jim/ref_f-g.htm#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" tppabs="http://www.nease.net/~jim/ref_s-s.htm#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" tppabs="http://www.nease.net/~jim/ref_m-q.htm#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" tppabs="http://www.nease.net/~jim/ref_a-c.htm#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" tppabs="http://www.nease.net/~jim/ref_m-q.htm#password_object">password</A>, <A HREF="ref_s-s.htm#select_object" tppabs="http://www.nease.net/~jim/ref_s-s.htm#select_object">select</A>, <A HREF="ref_t-z.htm#text_object" tppabs="http://www.nease.net/~jim/ref_t-z.htm#text_object">text</A>, <A HREF="ref_t-z.htm#textarea_object" tppabs="http://www.nease.net/~jim/ref_t-z.htm#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" tppabs="http://www.nease.net/~jim/ref_a-c.htm#blur_method">blur</A>, <A HREF="ref_s-s.htm#select_method" tppabs="http://www.nease.net/~jim/ref_s-s.htm#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" tppabs="http://www.nease.net/~jim/ref_s-s.htm#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" tppabs="http://www.nease.net/~jim/ref_s-s.htm#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" tppabs="http://www.nease.net/~jim/ref_a-c.htm#big_method">big</A>, <A HREF="ref_s-s.htm#small_method" tppabs="http://www.nease.net/~jim/ref_s-s.htm#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>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -