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

📄 methods.html

📁 javascript中文教程
💻 HTML
📖 第 1 页 / 共 4 页
字号:
<H3>Examples</H3>
<P>xxx Examples to be supplied.

<H3>See also</H3>
<LI><A HREF=#back_method>back</A>, <A HREF=#forward_method>forward</A> methods
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="indexOf_method"><H2>indexOf method</H2></A>
<P>
Returns the index within the calling string object of the first occurrence of the specified character, starting the search at <I>fromIndex</I>.

<H3>Syntax</H3>
<PRE>indexOf(<I>character</I>, [<I>fromIndex</I>])</PRE>
<P><I>character</I> is the character to search for.
<BR><I>fromIndex</I> is the location within the calling string to start the search from, any integer from 0 to string.length() - 1.

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

<H3>Applies to</H3>
<P><A HREF=objects.html#string_object>string</A>

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

<H3>See also</H3>
<LI><A HREF=#charAt_method>charAt</A>, <A HREF=#lastIndexOf_method>lastIndexOf</A> methods
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="italics_method"><H2>italics method</H2></A>
<P>
Causes the calling string object to be italicized by surrounding it with HTML italics tags, <TT>  &ltI&gt ... &lt/I&gt.</TT>
<! xxx Check to see if the method name is "italic" or "italics" -->

<H3>Syntax</H3>
<PRE>italics()</PRE>
<B>NOTE:</b> For Beta4, use I() for this method.

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

<H3>Applies to</H3>
<P><A HREF=objects.html#string_object>string</A>

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

<H3>See also</H3>
<LI><A HREF=#blink_method>blink</A>, <A HREF=#bold_method>bold</A>, <A HREF=#strike_method>strike</A> methods
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="lastIndexOf_method"><H2>lastIndexOf method</H2></A>
<P>
Returns the index within the calling string object of the last occurrence of the specified character. The calling string is searched backwards, starting at <I>fromIndex</I>.


<H3>Syntax</H3>
<PRE>indexOf(<I>character</I>, [<I>fromIndex</I>])</PRE>
<P><I>character</I> is the character to search for.
<BR><I>fromIndex</I> is the location within the calling string to start the search from, any integer from 0 to string.length() - 1.

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

<H3>Applies to</H3>
<P><A HREF=objects.html#string_object>string</A>

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

<H3>See also</H3>
<LI><A HREF=#charAt_method>charAt</A>, <A HREF=#indexOf_method>indexOf</A> methods
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="link_method"><H2>link method</H2></A>
<P>
Causes the calling string object to be a hyperlink by surrounding it with HTML hyperlink tags, <TT> &ltA HREF=...&gt &lt/A&gt.</TT>

<H3>Syntax</H3>
<PRE>link(<I>location</I>)</PRE>
The argument to the method, <I>location</I>, should be a valid URL.

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

<H3>Applies to</H3>
<P><A HREF=objects.html#string_object>string</A>

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

<H3>See also</H3>
<LI><A HREF=#anchor_method>anchor</A> method
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="log_method"><H2>log method</H2></A>
<P>
Returns the natural logarithm (base <I>e</I>) of its argument.

<H3>Syntax</H3>
<PRE>log(<I>arg</I>)</PRE>

<H3>Applies to</H3>
<P><A HREF=objects.html#Math_object>Math</A>

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

<H3>See also</H3>
<LI><A HREF=#exp_method>exp</A> method
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="max_method"><H2>max method</H2></A>
<P>
Returns the greater of its two arguments.

<H3>Syntax</H3>
<PRE>max(<I>arg1, arg2</I>)</PRE>

<H3>Applies to</H3>
<P><A HREF=objects.html#Math_object>Math</A>

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

<H3>See also</H3>
<LI><A HREF=#min_method>min</A> method
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="min_method"><H2>min method</H2></A>
<P>
Returns the lesser of its two arguments.

<H3>Syntax</H3>
<PRE>min(<I>arg1, arg2</I>)</PRE>

<H3>Applies to</H3>
<P><A HREF=objects.html#Math_object>Math</A>

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

<H3>See also</H3>
<LI><A HREF=#max_method>max</A> method
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="open_method"><H2>open method</H2></A>
<P>
For the window object, opens a new web browser window. xxx For the document object, description to be supplied.

<H3>Syntax</H3>
<P>The first form of the syntax is for the document object; the second form is for window.
<PRE>1. document.open("MIME type")
2. window.open("<I>URL</I>", "<I>windowName</I>", ["<I>windowFeatures</I>"])</PRE>
<P>
<I>URL</I> specifies the URL to open in the new window.
<BR><I>windowName</I> specifies a name for the window object being opened.
<BR><I>windowFeatures</I> is a comma-separated list of any of the following options and values:
<PRE>
   toolbar[=yes|no]|[=1|0]
   location[=yes|no]|[=1|0]
   directories[=yes|no]|[=1|0]
   status[=yes|no]|[=1|0]
   menubar[=yes|no]|[=1|0]
   scrollbars[=yes|no]|[=1|0]
   resizable[=yes|no]|[=1|0]
   copyhistory[=yes|no]|[=1|0]
   width=<I>pixels</I>
   height=<I>pixels</I>
</PRE>
<P>You may use any subset of these options.  Separate options with a comma.
Do not put spaces between the options.
<P><I>pixels</I> is a positive integer specifying the dimension in pixels.
<P>
<b>NOTE:</b>
In event handlers, you must specify window.open() unless you want to call document.open()
because of the scoping of static objects in JavaScript.

<H3>Description for window</H3>
<P>The open method opens a new web browser window on the client, similar to choosing File|New Web Browser from the menu of the Navigator. The <I>URL</I> argument specifies the URL contained by the new window. If <I>URL</I> is an empty string, a new, empty window is created.

<P><I>windowFeatures</I> is an optional, comma-separated list of options for the new window. The boolean <I>windowFeatures</I> options are set to true if they are specified without values, or as <TT>yes</TT> or <TT>1</TT>. For example, <TT>open("", "messageWindow", "toolbar")</TT> and <TT>open("", "messageWindow", "toolbar=1")</TT> both set the toolbar option to true. If <I>windowName</I> does not specify an existing window and you do not specify <I>windowFeatures</I>, all boolean <I>windowFeatures</I> are true by default.

<P>Following is a description of the <I>windowFeatures</I>:
<LI><I>toolbar</I> creates the standard Navigator toolbar, with buttons such as "Back" and "Forward", if true
<LI><I>location</I> creates a Location entry field, if true
<LI><I>directories</I> creates the standard Navigator directory buttons, such as "What's New" and "What's Cool", if true
<LI><I>status</I> creates the status bar at the bottom of the window, if true
<LI><I>menubar</I> creates the menu at the top of the window, if true
<LI><I>scrollbars</I> creates horizontal and vertical scrollbars when the document grows larger than the window dimensions, if true
<LI><I>resizable</I> allows a user to resize the window, if true
<LI><I>copyhistory</I> gives the new window the same session history as the current window, if true
<LI><I>width</I> specifies the width of the window in pixels
<LI><I>height</I> specifies the height of the window in pixels

<H3>Description for document</H3>
<P>Description to be supplied.

<H3>Applies to</H3>
<P><A HREF=objects.html#document_object>document</A>, <A HREF=objects.html#window_object>window</A>

<H3>Examples</H3>
<P>In the following example, the windowOpener function opens a window and uses write methods to display a message:
<PRE>function windowOpener() {
   msgWindow=open("","Display window","toolbar=no,directories=no,menubar=no");
   msgWindow.document.write("&ltHEAD&gt&ltTITLE&gtMessage window&lt/TITLE&gt&lt/HEAD&gt");
   msgWindow.document.write("&ltCENTER&gt&ltBIG&gt&ltB&gtHello, world!&lt/B&gt&lt/BIG&gt&lt/CENTER&gt");
}
</PRE>
<P>
The following is an onClick event handler that opens a new client window displaying
the content specified in the file <i>sesame.html</i>.
It opens it with the specified option settings and
names the corresponding window object newWin.
<xmp>
<FORM NAME="myform">
<INPUT TYPE="button" NAME="Button1" VALUE="Open Sesame!" 
onClick="window.open('sesame.html', 'newWin', 
'toolbar=no,directories=no,menubar=no,status=yes,width=300,height=300')">
</form>
</xmp>
<P>
Notice the use of single quotes (') inside the onClick event handler.


<H3>See also</H3>
<LI><A HREF=#close_method>close</A> method
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="parse_method"><H2>parse method</H2></A>
<H3>Syntax</H3>
<PRE>Date.parse(<i>date string</i>)</PRE>

<H3>Description</H3>
<P>
The parse function takes a date string (such as "Dec 25, 1995"), and returns the number
of milliseconds since January 1, 1970 00:00:00 (local time).
This function is useful for setting date values based on string values,
for example in conjunction with the setTime method.
<P>
Given a string representing a time, parse returns the time value. It accepts 
the IETF standard date syntax: "Mon, 25 Dec 1995 13:30:00 GMT". 
It understands the continental US time zone abbreviations, but for general use, 
use a time zone offset, for example "Mon, 25 Dec 1995 13:30:00 GMT+0430" 
(4 hours, 30 minutes west of the Greenwich meridian). If you do not specify a time zone,
the local time zone is assumed. GMT and UTC are considered equivalent. 

<P>
The parse function is a static method of Date.  That means that you always use it as
<code>Date.parse()</code>, rather than as a method of a date object you created.

<H3>Applies to</H3>
<P><A HREF=objects.html#Date_object>Date</A>

<H3>Examples</H3>
<P>
If IPOdate is an existing date object, then 
<PRE>
IPOdate.setTime(Date.parse("Aug 9, 1995"))
</PRE>

<H3>See also</H3>
<LI><A HREF=#UTC_method>UTC</A> method
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="pow_method"><H2>pow method</H2></A>
<P>
Returns <I>arg1</I> to the <I>arg2</I> power, i.e. arg1<sup>arg2</sup>.

<H3>Syntax</H3>
<PRE>pow(<I>arg1, arg2</I>)</PRE>

<H3>Applies to</H3>
<P><A HREF=objects.html#Math_object>Math</A>

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

<H3>See also</H3>
<LI><A HREF=#sqrt_method>sqrt</A> method
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="prompt_method"><H2>prompt method</H2></A>
<P>
Displays an Prompt dialog box with a message and an input field

<H3>Syntax</H3>
<PRE>prompt(<I>message</I>, <i>input default</i>)</PRE>

<H3>Description</H3>
<P>Use the prompt method to display a dialog box that takes user input.
The arguments, <I>message</I> and <i>input default</i> are
JavaScript values to be displayed as the message and the default value in the input field, respectively.

<H3>Applies to</H3>
<P><A HREF=objects.html#window_object>window</A>

<H3>Examples</H3>
<PRE>
prompt("Enter the number of doughnuts you want:", 12)
</PRE>

<H3>See also</H3>
<LI><A HREF=#alert_method>alert</A>, <A HREF=#confirm_method>confirm</A> methods
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="random_method"><H2>random method</H2></A>
<P>
Returns a pseudo-random number between zero and one. xxx NYI.

<H3>Syntax</H3>
<P>xxx To be supplied.

<H3>Applies to</H3>
<P><A HREF=objects.html#Math_object>Math</A>

<H3>Examples</H3>
<P>xxx Examples to be supplied.
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="round_method"><H2>round method</H2></A>
<P>
Returns its argument, rounded to the nearest integer. In other words, if its argument is <I>n</I>.5 or greater (where <I>n</I> is an integer), returns <I>n</I>+1, otherwise returns <I>n</I>.

<H3>Syntax</H3>
<PRE>round(<I>arg</I>)</PRE>

<H3>Applies to</H3>
<P><A HREF=objects.html#Math_object>Math</A>

<H3>Examples</H3>
<P>xxx Examples to be supplied.
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="select_method"><H2>select method</H2></A>
<P>
For password, text, and textArea, selects the input area of the object.

<H3>Syntax</H3>
<PRE>select()</PRE>

<H3>Description</H3>
<P>Use the select method to highlight the input area of a form element. You can use the select method with the focus method to highlight a field and position the cursor for a user response.

<H3>Applies to</H3>
<P><A HREF=objects.html#password_object>password</A>, <A HREF=objects.html#text_object>text</A>, <A HREF=objects.html#textArea_object>textArea</A>

<H3>Examples</H3>
<P>In the following example, the checkPassword function confirms that a user has entered a valid password. If the password is not valid, the select method highlights the password field and focus method returns focus to 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>&ltINPUT TYPE=password NAME=userPass&gt</PRE>

<H3>See also</H3>
<LI><A HREF=#blur_method>blur</A>, <A HREF=#focus_method>focus</A> methods
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="setDate_method"><H2>setDate method</H2></A>
<H3>Syntax</H3>
<CODE>dateObj.setDate(<i>day</I>)</CODE>
<P>
where <code>dateObj</code> is a date object.

<H3>Description</H3>
<P>
Sets the day of the month for the date object.
The argument is an integer from 1 to 31.

<H3>Applies to</H3>
<P><A HREF=objects.html#Date_object>Date</A>

<H3>Examples</H3>
<P>
The second statement below changes the day for theBigDay to the 24th of July from its original value.
<PRE>
theBigDay = new Date("July 27, 1962 23:30:00")
Xmas95.setDate(24)
</PRE>


<H3>See also</H3>
<LI>xxx To be supplied.
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="setHours_method"><H2>setHours method</H2></A>
<H3>Syntax</H3>
<CODE>dateObj.setHours(<i>hours</i> </CODE>
<P>
where <code>dateObj</code> is a date object.

<H3>Description</H3>
<P>
Sets the hours in the current time.
The argument is an integer between 0 and 23.

<H3>Applies to</H3>
<P><A HREF=objects.html#Date_object>Date</A>

<H3>Examples</H3>
<PRE>
theBigDay.setHours(7)
</PRE>

<H3>See also</H3>
<LI>xxx To be supplied.
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="setMinutes_method"><H2>setMinutes method</H2></A>
<H3>Syntax</H3>
<P><CODE>dateObj.setMinutes(<i>minutes</i>) </CODE>
<P>
where <code>dateObj</code> is a date object.

<H3>Description</H3>
<P>
Sets the minutes in the current time. The argument is an integer between 0 and 59.

<H3>Applies to</H3>
<P><A HREF=objects.html#Date_object>Date</A>

<H3>Examples</H3>
<PRE>
theBigDay.setMinutes(45)
</PRE>

<H3>See also</H3>
<LI>xxx To be supplied.
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="setMonth_method"><H2>setMonth method</H2></A>
<H3>Syntax</H3>
<CODE>dateObj.setMonth(<i>month</i>) </CODE>
<P>
where <code>dateObj</code> is a date object.

<H3>Description</H3>
<P>
Sets the month in the current date. The argument is an integer between 0 and 11.

<H3>Applies to</H3>
<P><A HREF=objects.html#Date_object>Date</A>

<H3>Examples</H3>
<PRE>
theBigDay.setMonth(6)
</PRE>

<H3>See also</H3>
<LI>xxx To be supplied.
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="setSeconds_method"><H2>setSeconds method</H2></A>
<H3>Syntax</H3>
<CODE>dateObj.setSeconds(<i>seconds</i>) </CODE>
<P>
where <code>dateObj</code> is a date object.

⌨️ 快捷键说明

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