⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 objects.html

📁 学习源代码
💻 HTML
📖 第 1 页 / 共 4 页
字号:


<H3>See also</H3>
<LI>xxx to be supplied


<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="Math_object"><H2>Math object (common)</H2></A>
<P>The built-in Math object has properties and methods for mathematical constants and functions. For example, the Math object's PI property has the value of pi.


<H3>Syntax</H3>
<PRE>
Math.<I>propertyName</I>
or
Math.<I>methodName</I>(<I>parameters</I>)
</PRE>


<H3>Description</H3>
<P>You reference the constant PI as <TT>Math.PI</TT>. Constants are defined with the full precision of real numbers in JavaScript.
<P>
Similarly, you reference Math functions as methods. For example, the sine function is <TT>Math.sin(<I>argument</I>)</TT>, where <I>argument</I> is the argument.
<P>
It is often convenient to use the <B>with</B> statement when a section of code uses several Math constants and methods, so you don't have to type "Math" repeatedly. For example,
<PRE>
with Math {
   a = PI * r*r;
   y = r*sin(theta)
   x = r*cos(theta)
}
</PRE>


<H3>Properties</H3>
<LI><A HREF="props.html#E_property" tppabs="http://www.webjx.com#E_property">E</A>
<LI><A HREF="props.html#LN10_property" tppabs="http://www.webjx.com#LN10_property">LN10</A>
<LI><A HREF="props.html#LN2_property" tppabs="http://www.webjx.com#LN2_property">LN2</A>
<LI><A HREF="props.html#PI_property" tppabs="http://www.webjx.com#PI_property">PI</A>
<LI><A HREF="props.html#SQRT1_2_property" tppabs="http://www.webjx.com#SQRT1_2_property">SQRT1_2</A>
<LI><A HREF="props.html#SQRT2_property" tppabs="http://www.webjx.com#SQRT2_property">SQRT2</A>


<H3>Methods</H3>
<LI><A HREF="methods.html#abs_method" tppabs="http://www.webjx.com#abs_method">abs</A>
<LI><A HREF="methods.html#acos_method" tppabs="http://www.webjx.com#acos_method">acos</A>
<LI><A HREF="methods.html#asin_method" tppabs="http://www.webjx.com#asin_method">asin</A>
<LI><A HREF="methods.html#atan_method" tppabs="http://www.webjx.com#atan_method">atan</A>
<LI><A HREF="methods.html#ceil_method" tppabs="http://www.webjx.com#ceil_method">ceil</A>
<LI><A HREF="methods.html#cos_method" tppabs="http://www.webjx.com#cos_method">cos</A>
<LI><A HREF="methods.html#exp_method" tppabs="http://www.webjx.com#exp_method">exp</A>
<LI><A HREF="methods.html#floor_method" tppabs="http://www.webjx.com#floor_method">floor</A>
<LI><A HREF="methods.html#log_method" tppabs="http://www.webjx.com#log_method">log</A>
<LI><A HREF="methods.html#max_method" tppabs="http://www.webjx.com#max_method">max</A>
<LI><A HREF="methods.html#min_method" tppabs="http://www.webjx.com#min_method">min</A>
<LI><A HREF="methods.html#pow_method" tppabs="http://www.webjx.com#pow_method">pow</A>
<LI><A HREF="methods.html#random_method" tppabs="http://www.webjx.com#random_method">random</A>
<LI><A HREF="methods.html#round_method" tppabs="http://www.webjx.com#round_method">round</A>
<LI><A HREF="methods.html#sin_method" tppabs="http://www.webjx.com#sin_method">sin</A>
<LI><A HREF="methods.html#sqrt_method" tppabs="http://www.webjx.com#sqrt_method">sqrt</A>
<LI><A HREF="methods.html#tan_method" tppabs="http://www.webjx.com#tan_method">tan</A>


<H3>Event handlers</H3>
<P>
None. Built-in objects do not have event handlers.


<H3>Examples</H3>
<P>xxx to be supplied


<H3>See also</H3>
<LI>xxx to be supplied


<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="password_object"><H2>password object (client)</H2></A>
<! xxx ->
<! xxx Rand says: Do not document password now. It may go in later, but not now. ->
<! xxx ->
<P>A password object is a text field on an HTML form. When the user enters text into the field, asterisks (*) hide anything entered from view.


<H3>Syntax</H3>
<P>To define a password object, use standard HTML syntax:
<PRE>
&LTINPUT

   TYPE="password"
   NAME="<I>objectName</I>"
   [VALUE="<I>textValue</I>"]
   SIZE=<I>integer</I>
</PRE>


<H3>Description</H3>
<P>xxx to be supplied


<H3>Properties</H3>
<LI><A HREF="props.html#defaultValue_property" tppabs="http://www.webjx.com#defaultValue_property">defaultValue</A>
<LI><A HREF="props.html#name_property" tppabs="http://www.webjx.com#name_property">name</A>
<LI><A HREF="props.html#value_property" tppabs="http://www.webjx.com#value_property">value</A>


<H3>Methods</H3>
<LI><A HREF="methods.html#focus_method" tppabs="http://www.webjx.com#focus_method">focus</A>
<LI><A HREF="methods.html#blur_method" tppabs="http://www.webjx.com#blur_method">blur</A>
<LI><A HREF="methods.html#select_method" tppabs="http://www.webjx.com#select_method">select</A>


<H3>Event handlers</H3>
<P>None.


<H3>Examples</H3>
<P>
<XMP>
<B>Password:</B> <INPUT TYPE="password" NAME="password" VALUE="" SIZE=25>
</XMP>


<H3>See also</H3>
<LI>xxx to be supplied


<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="radioButton_object"><H2>radioButton object (client)</H2></A>
<P>A radioButton object is a set of radio buttons on an HTML form. A set of radio buttons lets the user choose one item from a list.


<H3>Syntax</H3>
<P>To define a set of radio buttons, use standard HTML syntax with the addition of the onClick event handler:
<PRE>
&LTINPUT

   TYPE="radio"
   NAME="<I>objectName</I>"
   VALUE="<I>buttonValue</I>"
   [CHECKED]
   [onClick="<I>handlerText</I>"]&GT

   <I>textToDisplay</I>
</PRE>
<P><I>NAME</I> should contain the same value for all radio buttons in a group.


<H3>Description</H3>
<P>All radio buttons in a radio button group use the same name property. To access the individual radio buttons in your code, follow the object name with an index starting from zero, one for each button the same way you would for an array such as <I>forms</I>: <TT>document.forms[0].<I>objectName</I>[0]</TT> is the first, <TT>document.forms[0].<I>objectName</I>[1]</TT> is the second, etc.


<H3>Properties</H3>
<LI><A HREF="props.html#checked_property" tppabs="http://www.webjx.com#checked_property">checked</A>
<LI><A HREF="props.html#defaultChecked_property" tppabs="http://www.webjx.com#defaultChecked_property">defaultChecked</A>
<LI><A HREF="props.html#index_property" tppabs="http://www.webjx.com#index_property">index</A>
<LI><A HREF="props.html#length_property" tppabs="http://www.webjx.com#length_property">length</A>
<LI><A HREF="props.html#name_property" tppabs="http://www.webjx.com#name_property">name</A>
<LI><A HREF="props.html#value_property" tppabs="http://www.webjx.com#value_property">value</A>


<H3>Methods</H3>
<LI><A HREF="methods.html#click_method" tppabs="http://www.webjx.com#click_method">click</A>


<H3>Event handlers</H3>
<LI><A HREF="events.html#onClick_event" tppabs="http://www.webjx.com#onClick_event">onClick</A>


<H3>Examples</H3>
<P>
The following example defines a radio button group to choose among three catalogs. Each radio button is given the same name, <I>NAME="choice"</I>, forming a group of buttons for which only one choice can be selected. The example also defines a text field that defaults to what was chosen via the radio buttons but that allows the user to type a nonstandard catalog name as well. JavaScript automatically sets the catalog name input field based on the radio buttons.
<XMP>
<INPUT TYPE="text" NAME="catalog" SIZE="20">
<INPUT TYPE="radio" NAME="choice" VALUE="PRICEY"
   onClick="form.catalog.value = 'top-of-the-line'"> It's really great!
<INPUT TYPE="radio" NAME="choice" VALUE="MODEST"
   onClick="form.catalog.value = 'middle-of-the-road'"> It's pretty good.
<INPUT TYPE="radio" NAME="choice" VALUE="CHEAPO"
   onClick="form.catalog.value = 'bargain-basement'"> It stinks!
</XMP>


<H3>See also</H3>
<LI><A HREF=#selection_object>selection</A> object


<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="reset_object"><H2>reset object (client)</H2></A>
<P>A reset object is a reset button on an HTML form.


<H3>Syntax</H3>
<P>To define a reset button, use standard HTML syntax with the addition of the onClick event handler:
<PRE>
&LTINPUT

   [NAME="<I>objectName</I>"]
   TYPE="reset"
   VALUE="<I>buttonText</I>"
   [onClick="<I>handlerText</I>"]&GT

</PRE>
<I>VALUE</I> specifies the text to display on the button face and can be accessed using the value property.


<H3>Description</H3>
<P>A reset button resets all elements in a form to their defaults.


<H3>Properties</H3>
<LI><A HREF="props.html#name_property" tppabs="http://www.webjx.com#name_property">name</A>
<LI><A HREF="props.html#value_property" tppabs="http://www.webjx.com#value_property">value</A>


<H3>Methods</H3>
<LI><A HREF="methods.html#click_method" tppabs="http://www.webjx.com#click_method">click</A>


<H3>Event handlers</H3>
<LI><A HREF="events.html#onClick_event" tppabs="http://www.webjx.com#onClick_event">onClick</A>


<H3>Examples</H3>
<P>The following example displays a text object containing "CA". If the user types a different state abbreviation in the text object and then clicks the Clear Form button, the original value of "CA" is restored.
<XMP>
<B>State: </B><INPUT TYPE="text" NAME="state" VALUE="CA" SIZE="2">
<P><INPUT TYPE="reset" VALUE="Clear Form">
</XMP>


<H3>See also</H3>
<LI><A HREF=#button_object>button</A> and <A HREF=#submit_object>submit</A> objects


<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="selection_object"><H2>selection object (client)</H2></A>
<! xxx ->
<! xxx Brendan wonders if this should be "select object", to match the syntax. ->
<! xxx Note that link and radioButton have similar inconsistencies. ->
<! xxx ->
<P>A selection object is 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 selection object, use standard HTML syntax with the addition of the onBlur, onChange, and onFocus event handlers:
<PRE>
&LTSELECT

   NAME="<I>objectName</I>"
   [SIZE="<I>value</I>"]
   [MULTIPLE]
   [onBlur="<I>handlerText</I>"]
   [onChange="<I>handlerText</I>"]
   [onFocus="<I>handlerText</I>"]&GT

   &LTOPTION [SELECTED]&GT <I>textToDisplay</I> [ ... &LTOPTION> <I>textToDisplay</I>]
&LT/SELECT>

</PRE>

<P><I>SIZE</I> specifies the number of options visible when the form is displayed.


<H3>Description</H3>
<P>You can reference the options of a selection object in your code by using the options property. The options property is an array that contains an entry for each option in a selection object. Each option has the properties listed below.

<P>The options on selection objects can be updated dynamically. xxx NYI.


<H3>Properties</H3>
<! xxx ->
<! xxx This needs to be thought through. In PROPS.HTML, the options properties say ->
<! xxx they apply to selection object. Need to improve. ->
<! xxx ->
<P>The selection object has the following properties:
<LI><A HREF="props.html#options_property" tppabs="http://www.webjx.com#options_property">options</A>
<LI><A HREF="props.html#selectedIndex_property" tppabs="http://www.webjx.com#selectedIndex_property">selectedIndex</A>
<P>The options property has the following properties:
<LI><A HREF="props.html#defaultSelected_property" tppabs="http://www.webjx.com#defaultSelected_property">defaultSelected</A>
<LI><A HREF="props.html#index_property" tppabs="http://www.webjx.com#index_property">index</A>
<LI><A HREF="props.html#selected_property" tppabs="http://www.webjx.com#selected_property">selected</A>
<LI><A HREF="props.html#text_property" tppabs="http://www.webjx.com#text_property">text</A>
<LI><A HREF="props.html#value_property" tppabs="http://www.webjx.com#value_property">value</A>


<H3>Methods</H3>
<LI><A HREF="methods.html#click_method" tppabs="http://www.webjx.com#click_method">click</A>


<H3>Event handlers</H3>
<LI><A HREF="events.html#onBlur_event" tppabs="http://www.webjx.com#onBlur_event">onBlur</A>
<LI><A HREF="events.html#onChange_event" tppabs="http://www.webjx.com#onChange_event">onChange</A>
<LI><A HREF="events.html#onFocus_event" tppabs="http://www.webjx.com#onFocus_event">onFocus</A>


<H3>Examples</H3>
<P>The following example displays a selection 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:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -