📄 methods.html
字号:
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" tppabs="http://www.webjx.com/js/objects.html#document_object">document</A>, <A HREF="objects.html#window_object" tppabs="http://www.webjx.com/js/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("<HEAD><TITLE>Message window</TITLE></HEAD>");
msgWindow.document.write("<CENTER><BIG><B>Hello, world!</B></BIG></CENTER>");
}
</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" tppabs="http://www.webjx.com/js/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" tppabs="http://www.webjx.com/js/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" tppabs="http://www.webjx.com/js/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" tppabs="http://www.webjx.com/js/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" tppabs="http://www.webjx.com/js/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" tppabs="http://www.webjx.com/js/objects.html#password_object">password</A>, <A HREF="objects.html#text_object" tppabs="http://www.webjx.com/js/objects.html#text_object">text</A>, <A HREF="objects.html#textArea_object" tppabs="http://www.webjx.com/js/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><INPUT TYPE=password NAME=userPass></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" tppabs="http://www.webjx.com/js/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" tppabs="http://www.webjx.com/js/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" tppabs="http://www.webjx.com/js/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" tppabs="http://www.webjx.com/js/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.
<H3>Description</H3>
<P>
Sets the seconds in the current time. The argument is an integer between 0 and 59.
<H3>Applies to</H3>
<P><A HREF="objects.html#Date_object" tppabs="http://www.webjx.com/js/objects.html#Date_object">Date</A>
<H3>Examples</H3>
<PRE>
theBigDay.setSeconds(30)
</PRE>
<H3>See also</H3>
<LI>xxx To be supplied.
<!---------------------------------------------------------------------------->
<HR>
<A NAME="setTime_method"><H2>setTime method</H2></A>
<H3>Syntax</H3>
<P><CODE>dateObj.setTime(<i>timevalue</i>) </CODE>
<P>
where <code>dateObj</code> is a date object.
<H3>Description</H3>
<P>
Sets the value of the date object.
This argument is the number of milliseconds since the epoch
(1 January 1970 00:00:00)
You can use this method to help assign a date and time to another date object.
<H3>Applies to</H3>
<P><A HREF="objects.html#Date_object" tppabs="http://www.webjx.com/js/objects.html#Date_object">Date</A>
<H3>Examples</H3>
<PRE>
theBigDay = new Date("July 1, 1999")
sameAsBigDay = new Date();
sameAsBigDay.setTime(theBigDay.getTime())
</PRE>
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="setTimeout_method"><H2>setTimeout method</H2></A>
<P>Evaluates an expression after a specified number of milliseconds have elapsed.
<H3>Syntax</H3>
<PRE><I>timeoutID</I>=setTimeout(<I>expression</I>, <I>msec</I>)</PRE>
<P><I>expression</I> is a string expression.
<BR><I>msec</I> is a numeric value or numeric string in millisecond units.
<BR><I>timeoutID</I> is an identifier that is used only to cancel the evaluation with the clearTimeout method.
<H3>Description</H3>
<P>xxx Description to be supplied.
<! xxx See Brendan's email for more information.
<H3>Applies to</H3>
<P><A HREF="objects.html#window_object" tppabs="http://www.webjx.com/js/objects.html#window_object">window</A>
<H3>Examples</H3>
<P>xxx Examples to be supplied.
<H3>See also</H3>
<LI><A HREF=#clearTimeout_method>clearTimeout</A>
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="setYear_method"><H2>setYear method</H2></A>
<H3>Syntax</H3>
<CODE>dateObj.setYear(<i>year</i>) </CODE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -