📄 ref_s-s.htm
字号:
<TT><P><B>Hello, world</B></TT>
<TT><P><I>Hello, world</I></TT>
<TT><P><STRIKE>Hello, world</STRIKE></TT>
</PRE>
<H3>相关</H3>
<LI><A HREF="ref_a-c.htm#blink_method" blink_method">blink</A>, <A HREF="ref_a-c.htm#bold_method" bold_method">bold</A>, <A HREF="ref_h-l.htm#italics_method" italics_method">italics</A> methods
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="string_object"><H2>string object</H2></A>
<P>A series of characters.
<H3>语法</H3>
<P>To use a string object:
<PRE>
1. <I>stringName</I>.<I>propertyName</I>
2. <I>stringName</I>.<I>methodName</I>(<I>parameters</I>)
</PRE>
<I>stringName</I> is the name of a string variable.
<BR><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>None.
<H3>描述</H3>
<P>The string object is a built-in JavaScript object.
<P>A string can be represented as a literal enclosed by single or double quotes; for example, "Netscape" or 'Netscape'.
<H3>Properties</H3>
<LI><A HREF="ref_h-l.htm#length_property" length_property">length</A> reflects the length of the string
<H3>Methods</H3>
<LI><A HREF="ref_a-c.htm#anchor_method" anchor_method">anchor</A>
<LI><A HREF="ref_a-c.htm#big_method" big_method">big</A>
<LI><A HREF="ref_a-c.htm#blink_method" blink_method">blink</A>
<LI><A HREF="ref_a-c.htm#bold_method" bold_method">bold</A>
<LI><A HREF="ref_a-c.htm#charAt_method" charAt_method">charAt</A>
<LI><A HREF="ref_f-g.htm#fixed_method" fixed_method">fixed</A>
<LI><A HREF="ref_f-g.htm#fontcolor_method" fontcolor_method">fontcolor</A>
<LI><A HREF="ref_f-g.htm#fontsize_method" fontsize_method">fontsize</A>
<LI><A HREF="ref_h-l.htm#indexOf_method" indexOf_method">indexOf</A>
<LI><A HREF="ref_h-l.htm#italics_method" italics_method">italics</A>
<LI><A HREF="ref_h-l.htm#lastIndexOf_method" lastIndexOf_method">lastIndexOf</A>
<LI><A HREF="ref_h-l.htm#link_method" link_method">link</A>
<LI><A HREF="ref_s-s.htm#small_method" small_method">small</A>
<LI><A HREF="ref_s-s.htm#strike_method" strike_method">strike</A>
<LI><A HREF="ref_s-s.htm#sub_method" sub_method">sub</A>
<LI><A HREF="ref_s-s.htm#substring_method" substring_method">substring</A>
<LI><A HREF="ref_s-s.htm#sup_method" sup_method">sup</A>
<LI><A HREF="ref_t-z.htm#toLowerCase_method" toLowerCase_method">toLowerCase</A>
<LI><A HREF="ref_t-z.htm#toUpperCase_method" toUpperCase_method">toUpperCase</A>
<H3>Event handlers</H3>
<LI>None. Built-in objects do not have event handlers.
<H3>例子</H3>
<P>The following statement creates a string variable.
<XMP>
var last_name = "Schaefer"
</XMP>
The following statements evaluate to 8, "SCHAEFER", and "schaefer":
<XMP>
last_name.length
last_name.toUpperCase()
last_name.toLowerCase()
</XMP>
<H3>相关</H3>
<LI><A HREF="ref_t-z.htm#text_object" text_object">text</A> and <A HREF="ref_t-z.htm#textarea_object" textarea_object">textarea</A> objects
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="sub_method"><H2>sub method</H2></A>
<P>
Causes a string to be displayed as a subscript as if it were in a <SUB> tag.
<H3>语法</H3>
<PRE><I>stringName</I>.sub()</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 sub method with the write or writeln methods to format and display a string in a document.
<H3>例子</H3>
The following example uses the sub and sup methods to format a string:
<PRE>
var superText="superscript"
var subText="subscript"
document.write("This is what a " + superText.sup() + " looks like.")
document.write("<P>This is what a " + subText.sub() + " looks like.")
</PRE>
<P>The previous example produces the same output as the following htm:
<PRE>
This is what a <SUP>superscript</SUP> looks like.
<P>This is what a <SUB>subscript</SUB> looks like.
</PRE>
<H3>相关</H3>
<P><A HREF="ref_s-s.htm#sup_method" sup_method">sup</A> method
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="submit_method"><H2>submit method</H2></A>
<P>
Submits a form.
<H3>语法</H3>
<PRE><I>formName</I>.submit()</PRE>
<P><I>formName</I> is the name of any form or an element in the forms array.
<H3>方法</H3>
<P><A HREF="ref_f-g.htm#form_object" form_object">form</A>
<H3>描述</H3>
<P>The submit method submits the specified form. It performs the same action as a submit button.
<P>Use the submit method to send data back to an http server. The submit method returns the data using either "get" or "post", as specified in the <A HREF="ref_m-q.htm#method_property" method_property">method</A> property.
<H3>例子</H3>
<P>The following example submits a form called <I>musicChoice</I>:
<PRE>
document.musicChoice.submit()
</PRE>
<P>If <I>musicChoice</I> is the first form created, you also can submit it as follows:
<PRE>
document.forms[0].submit()
</PRE>
<P>相关 the example for the <A HREF="ref_f-g.htm#form_object" form_object">form</A> object.
<H3>相关</H3>
<LI><A HREF="ref_s-s.htm#submit_object" submit_object">submit</A> object
<LI><A HREF="ref_m-q.htm#onSubmit_event" onSubmit_event">onSubmit</A> event handler
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="submit_object"><H2>submit object</H2></A>
<P>A submit button on an htm form. A submit button causes a form to be submitted.
<H3>语法</H3>
<P>To define a submit button, use standard htm 语法 with the addition of the onClick event handler:
<PRE>
<INPUT
TYPE="submit"
NAME="<I>submitName</I>"
VALUE="<I>buttonText</I>"
[onClick="<I>handlerText</I>"]>
</PRE>
<I>NAME="submitName"</I> specifies the name of the submit object. You can access this value using the name property.
<BR><I>VALUE="buttonText"</I> specifies the label to display on the button face. You can access this value using the value property.
<P>To use a submit object's properties and methods:
<PRE>
1. <I>submitName</I>.<I>propertyName</I>
2. <I>submitName</I>.<I>methodName</I>(<I>parameters</I>)
3. <I>formName</I>.elements[<I>index</I>].<I>propertyName</I>
4. <I>formName</I>.elements[<I>index</I>].<I>methodName</I>(<I>parameters</I>)
</PRE>
<I>submitName</I> is the value of the NAME attribute of a submit object.
<BR><I>formName</I> is either the value of the NAME attribute of a form object or an element in the <I>forms</I> array.
<BR><I>index</I> is an integer representing a submit object on a form.
<BR><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_f-g.htm#form_object" form_object">form</A>
<H3>描述</H3>
<P>A submit object on a form looks as follows:
<FORM>
<P><INPUT TYPE="submit" VALUE="Done">
</FORM>
<P>A submit object is a form element and must be defined within a <FORM> tag.
<P>Clicking a submit button submits a form to the URL specified by the form's action property. This action always loads a new page into the client; it may be the same as the current page, if the action so specifies or is not specified.
<P>The submit button's onClick event handler cannot prevent a form from being submitted; instead, use the form's onSubmit event handler or use the submit method instead of a submit object. See the 例子 for the <A HREF="ref_f-g.htm#form_object" form_object">form</A> object.
<H3>Properties</H3>
<LI><A HREF="ref_m-q.htm#name_property" name_property">name</A> reflects the NAME attribute
<LI><A HREF="ref_t-z.htm#value_property" value_property">value</A> reflects the VALUE attribute
<H3>Methods</H3>
<LI><A HREF="ref_a-c.htm#click_method" click_method">click</A>
<H3>Event handlers</H3>
<LI><A HREF="ref_m-q.htm#onClick_event" onClick_event">onClick</A>
<H3>例子</H3>
<P>The following example creates a submit object called <I>submit_button</I>. The text "Done" is displayed on the face of the button.
<XMP>
<INPUT TYPE="submit" NAME="submit_button" VALUE="Done">
</XMP>
<P>相关 the 例子 for the <A HREF="ref_f-g.htm#form_object" form_object">form</A> object.
<H3>相关</H3>
<LI><A HREF="ref_a-c.htm#button_object" button_object">button</A>, <A HREF="ref_f-g.htm#form_object" form_object">form</A>, and <A HREF="ref_r-r.htm#reset_object" reset_object">reset</A> objects
<LI><A HREF="ref_s-s.htm#submit_method" submit_method">submit</A> method
<LI><A HREF="ref_m-q.htm#onSubmit_event" onSubmit_event">onSubmit</A> event handler
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="substring_method"><H2>substring method</H2></A>
<P>
Returns a subset of a string object.
<H3>语法</H3>
<PRE><I>stringName</I>.substring(<I>indexA</I>, <I>indexB</I>)</PRE>
<P><I>stringName</I> is any string or a property of an existing object.
<BR><I>indexA</I> is any integer from 0 to <I>stringName</I>.length - 1, or a property of an existing object.
<BR><I>indexB</I> is any integer from 0 to <I>stringName</I>.length - 1, 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>Characters in a string are indexed from left to right. The index of the first character is 0, and the index of the last character is <I>stringName</I>.length - 1.
<P>If <I>indexA</I> is less than <I>indexB</I>, the substring method returns the subset starting with the character at <I>indexA</I> and ending with the character before <I>indexB</I>. If <I>indexA</I> is greater than <I>indexB</I>, the substring method returns the subset starting with the character at <I>indexB</I> and ending with the character before <I>indexA</I>. If <I>indexA</I> is equal to <I>indexB</I>, the substring method returns the empty string.
<H3>例子</H3>
The following example uses substring to display characters from the string "Netscape".
<PRE>
var anyString="Netscape"
//Displays "Net"
document.write(anyString.substring(0,3))
document.write(anyString.substring(3,0))
//Displays "cap"
document.write(anyString.substring(4,7))
document.write(anyString.substring(7,4))
</PRE>
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="sup_method"><H2>sup method</H2></A>
<P>
Causes a string to be displayed as a superscript as if it were in a <SUP> tag.
<H3>语法</H3>
<PRE><I>stringName</I>.sup()</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 sup method with the write or writeln methods to format and display a string in a document.
<H3>例子</H3>
The following example uses the sub and sup methods to format a string:
<PRE>
var superText="superscript"
var subText="subscript"
document.write("This is what a " + superText.sup() + " looks like.")
document.write("<P>This is what a " + subText.sub() + " looks like.")
</PRE>
<P>The previous example produces the same output as the following htm:
<PRE>
This is what a <SUP>superscript</SUP> looks like.
<P>This is what a <SUB>subscript</SUB> looks like.
</PRE>
<H3>相关</H3>
<LI><A HREF="ref_s-s.htm#sub_method" sub_method">sub</A> method
<!------------------------------------------------------------------------------------------------>
<HR>
<SCRIPT>
document.write("<FONT SIZE=-2>Last modified " + document.lastModified)
</SCRIPT>
<P>
</BODY>
<htm>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -