JavaScript的方法
以下的一些"方法"可用在JavaScript:
abs method
Returns the absolute value of its argument.
Syntax
abs(arg)
Applies to
Examples
xxx Examples to be supplied.
acos method
Returns the arc cosine (in radians) of its argument.
Syntax
acos(arg)
Applies to
Examples
xxx Examples to be supplied.
See also
- asin, atan, cos, sin, tan methods
alert method
Displays an Alert dialog box with a message and an OK button.
Syntax
alert("message")
The argument message is any string.
Description
Use the alert method to display a message that does not require a user decision. The message argument specifies a message that the dialog box contains.
Applies to
Examples
In the following example, the testValue function checks the name entered by a user in the text element of a form to make sure that it is no more than eight characters in length. This example uses the alert method to prompt the user of an application to enter a valid value.
function testValue(textElement) { if (textElement.length > 8) { alert("Please enter a name that is 8 characters or less") } }
You can call the testValue function in the onBlur event handler of a form's text element, as shown in the following example:Name: <INPUT TYPE="text" NAME="userName" onBlur="testValue(userName)">
See also
- confirm, prompt methods
anchor method
Causes the calling string object to be a named anchor by surrounding it with HTML anchor tags, <A NAME=...> </A>.
Syntax
string.anchor(name)
The argument name can be any string.
Description
xxx Description to be supplied.
Applies to
Examples
xxx Examples to be supplied.
See also
- link method
asin method
Returns the arc sine (in radians) of its argument.
Syntax
asin(arg)
Applies to
Examples
xxx Examples to be supplied.
See also
- acos, atan, cos, sin, tan methods
assign method
Sets location.href so you don't have to type ".href" complements toString().
Syntax
assign()
Description
Do not call the assign method. It exists so you can use 'location=...' instead of 'location.href=...'. xxx Description to be supplied.
Applies to
Examples
xxx Examples to be supplied.
atan method
Returns the arc tangent (in radians) of its argument.
Syntax
atan(arg)
Applies to
Examples
xxx Examples to be supplied.
See also
- acos, asin, cos, sin, tan methods
back method
Loads the previous URL in the history list.
Syntax
back()
Description
This method performs the same action as a user choosing the Back button in the Navigator. The back method is the same as go(-1).
Applies to
Examples
xxx Examples to be supplied.
See also
- forward, go methods
big method
Causes the calling string object to be displayed in big font by surrounding it with HTML big font tags, <BIG> and </BIG>.
Syntax
big()
Description
xxx Description to be supplied.
Applies to
Examples
xxx Examples to be supplied.
See also
- fontsize, small methods
blink method
Causes the calling string object to blink by surrounding it with HTML blink tags, <BLINK> ... </BLINK>.
Syntax
blink()
Description
xxx Description to be supplied.
Applies to
Examples
xxx Examples to be supplied.
See also
- bold, italics, strike methods
blur method
For password, text, and textArea, removes focus to the object.
Syntax
blur()
Description
Use the blur method to remove focus from a specific form element.
Applies to
Examples
xxx Examples to be supplied.
See also
- focus, select methods
bold method
Causes the calling string object to be displayed as bold by surrounding it with HTML bold tags, <B> ... </B>.
Syntax
bold()
NOTE: For Beta4, use B() for this method.Description
xxx Description to be supplied.
Applies to
Examples
xxx Examples to be supplied.
See also
- blink, italics, strike methods
ceil method
Returns the least integer greater than or equal to its argument.
Syntax
ceil(arg)
Applies to
Examples
xxx Examples to be supplied.
See also
- floor method
charAt method
Returns the character at the specified index.
Syntax
charAt(index)
index is any integer from 0 to string.length() - 1.
Description
xxx Description to be supplied.
Applies to
Examples
xxx Examples to be supplied.
See also
- indexOf, lastIndexOf methods
clear method
Clears the window.
Syntax
clear()
Description
xxx Description to be supplied.
Applies to
Examples
xxx Examples to be supplied.
clearTimeout method
Cancels a timeout that was set with the setTimeout method.
Syntax
clearTimeout(timeoutID)
timeoutID is a timeout setting that was returned by a previous call to the setTimeout method.
Description
xxx Description to be supplied. Applies to
Examples
xxx Examples to be supplied.
See also
- setTimeout
click method
Simulates a mouse click on the calling form element.
Syntax
click()
Description
The effect of the click method varies according to the calling element:
- For button, reset, and submit, xxx.
- For a radioButton, selects a radio button.
- For a checkbox, checks the check box and sets its value to on.
- For a selection, sets its value.
Applies to
button, checkbox, radioButton, reset, selection, submit
Examples
xxx Examples to be supplied.
close method
For document and window, closes the window. xxx Not yet implemented in Beta 4.
Syntax
close()
Description
Document description to be supplied.
The close method closes the current window.
Applies to
Examples
Any of the following examples close the current window:
window.close() self.close() close()
See also
- open method
confirm method
Displays a Confirm dialog box with the specified message and OK and Cancel buttons.
Syntax
confirm("message")
The argument message is any string.
Description
Use the confirm method to ask the user to make a decision that requires either an OK or a Cancel. The message argument specifies a message that prompts the user for the decison. The confirm method returns true if the user chooses OK and false if the user chooses Cancel.
Applies to
Examples
This example uses the confirm method in the confirmCleanUp function to confirm that the user of an application really wants to quit. If the user chooses OK, the custom cleanUp() function closes the application.
function confirmCleanUp() { if (confirm("Are you sure you want to quit this application?")) { cleanUp() } }
You can call the confirmCleanUp function in the onClick event handler of a form's pushbutton, as shown in the following example:<INPUT TYPE="button" VALUE="Quit" onClick="confirmCleanUp()">
See also
- alert, prompt methods
cos method
Returns the cosine of its argument. The argument is in radians.
Syntax
cos(arg)
Applies to
Examples
xxx Examples to be supplied.
See also
- acos, asin, atan, sin, tan methods
eval function
The eval function is a function built-in to JavaScript. It is not a method associated with any object, but is part of the language itself.
Syntax
eval(expression)
Description
The eval function takes a JavaScript arthimetic expression as its argument and returns the value of the argument as a number.
Example
Both of the uses of eval in the following example assign the value 42 to the variable result.
x = 6 result = eval((3+3)*7) result = eval(x*7)
exp method
Returns e to the power of its argument, i.e. ex, where x is the argument, and e is Euler's constant, the base of the natural logarithms.
Syntax
exp(arg)
Applies to
Examples
xxx Examples to be supplied.
See also
- log method
fixed method
Causes the calling string object to be displayed in fixed-pitch font in HTML by surrounding it with typewriter text tags, <fixed> ... </fixed>.
Syntax
fixed()
NOTE: For Beta4, use TT() for this method.Description
xxx Description to be supplied.
Applies to
Examples
xxx Examples to be supplied.
floor method
Returns the greatest integer less than or equal to its argument.
Syntax
floor(arg)
Applies to
Examples
xxx Examples to be supplied.
See also
- ceil method
focus method
For password, text, and textArea, gives focus to the object.
Syntax
focus()
Description
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.
Applies to
Examples
In the following example, the checkPassword function confirms that a user has entered a valid password. If the password is not valid, the focus method returns focus to the password field and the select method highlights it so the user can re-enter the password.
function checkPassword(userPass) { if (badPassword) { alert("Please enter your password again.") userPass.focus() userPass.select() } }
This example assumes that the password is defined as:<INPUT TYPE=password NAME=userPass>
See also
- blur, select methods
fontcolor method
Causes the calling string object to be displayed in the specified color by surrounding it with HTML font color tags, <FONTCOLOR=color> ... </FONTCOLOR>.
Syntax
fontcolor(color)
The argument to the method, color, must be a string containing a hashmark (#) followed by a triplet of hexadecimal number pairs. These three pairs represent the red, green, and blue values for the desired color, respectively.
Description
xxx Description to be supplied.
Applies to
Examples
xxx Examples to be supplied.
fontsize method
Causes the calling string object to be displayed in the specified font size by surrounding it with HTML font size tags, <FONTSIZE=size> ... </FONTSIZE>.
Syntax
fontsize(size)
The argument to the method, size, must be an integer between one and seven.
Description
xxx Description to be supplied.
Applies to
Examples
xxx Examples to be supplied.
See also
- big, small methods
forward method
Loads the next URL in the history list.
Syntax
forward()
Description
This method performs the same action as a user choosing the Forward button in the Navigator. The forward method is the same as go(1).
Applies to
Examples
xxx Examples to be supplied.
See also
- back, go methods
getDate method
Syntax
dateObj.getDate()
where
dateObj
is a date object.Description
Returns the day of the month for the date object, an integer between 1 and 31.
Applies to
Examples
The second statement below assigns the value 25 to the variable day, based on the value of the date object Xmas95.
Xmas95 = new Date("December 25, 1995 23:15:00") day = Xmas95.getDate()
See also
- xxx To be supplied.
getDay method
Syntax
dateObj.getDay()
where
dateObj
is a date object.Description
Returns the day of the week for the date object, an integer corresponding to the day of the week: zero for Sunday, one for Monday, two for Tuesday, and so on.
Applies to
Examples
The second statement below assigns the value 1 to weekday, based on the value of the date object Xmas95. This is because December 25, 1995 is a Monday.
Xmas95 = new Date("December 25, 1995 23:15:00") weekday = Xmas95.getDay()
See also
- xxx To be supplied.
getHours method
Syntax
dateObj.getHours()
where
dateObj
is a date object.Description
Returns the hour for the date object, an integer between 0 and 23.
Applies to
Examples
The second statement below assigns the value 23 to the variable hours, based on the value of the date object Xmas95.
Xmas95 = new Date("December 25, 1995 23:15:00") hours = Xmas95.getHours()
See also
- xxx To be supplied.
getMinutes method
Syntax
dateObjgetMinute()
where
dateObj
is a date object.Description
Returns the minutes in the date object, an integer between 0 and 59.
Applies to
Examples
The second statement below assigns the value 15 to the variable minutes, based on the value of the date object Xmas95.
Xmas95 = new Date("December 25, 1995 23:15:00") minutes = Xmas95.getMinutes()
See also
- xxx To be supplied.
getMonth method
Syntax
dateObj.getMonth()
where
dateObj
is a date object.Description
Returns the month in the date object, an integer between zero and eleven. Zero corresponds to January, one to Februrary, and so on.
Applies to
Examples
The second statement below assigns the value 11 to the variable month, based on the value of the date object Xmas95.
Xmas95 = new Date("December 25, 1995 23:15:00") month = Xmas95.getDate()
See also
- xxx To be supplied.
getSeconds method
Syntax
dateObj.getSeconds()
where
dateObj
is a date object.Description
Returns the seconds in the current time, an integer between 0 and 59.
Applies to
Examples
The second statement below assigns the value 30 to the variable secs, based on the value of the date object Xmas95.
Xmas95 = new Date("December 25, 1995 23:15:30") secs = Xmas95.getSeconds()
See also
- xxx To be supplied.
getTime method
Syntax
dateObj.getTime()
where
dateObj
is a date object.Description
Returns the numeric value for the date object. This number 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.
Applies to
Examples
The following example assigns the date value of theBigDay to sameAsBigDay.
theBigDay = new Date("July 1, 1999") sameAsBigDay = new Date(); sameAsBigDay.setTime(theBigDay.getTime())
See also
- xxx To be supplied.
getTimezoneOffset method
Syntax
dateObj.getTimezoneOffset()
where
dateObj
is a date object.Description
Return the time zone offset in minutes for the current locale, i.e. the difference between the local time and GMT. This value would be a constant except for daylight savings time.
Applies to
Examples
x = new Date(); currentTimeZoneOffsetInHours = x.getTimezoneOffset()/60;
See also
- xxx To be supplied.
getYear method
Syntax
getyear()
Description
Returns the year in the date object, less 1900.
Applies to
Examples
The second statement below assigns the value 95 to the variable year, based on the value of the date object Xmas95.
Xmas95 = new Date("December 25, 1995 23:15:00") year = Xmas95.getYear()
See also
- xxx To be supplied.
go method
The argument delta is an integer. If delta is greater than zero, then it loads the URL that is that number of entries forward in the history list; otherwise, it loads the URL that is that number of entries backward in the history list.
The argument string is a string. Go to the newest history entry whose title or URL contains string as a substring; substring matching is case-insensitive.
Syntax
go(delta | "string")
Description
xxx Description to be supplied.
Applies to
Examples
xxx Examples to be supplied.
See also
- back, forward methods
indexOf method
Returns the index within the calling string object of the first occurrence of the specified character, starting the search at fromIndex.
Syntax
indexOf(character, [fromIndex])
character is the character to search for.
fromIndex is the location within the calling string to start the search from, any integer from 0 to string.length() - 1.Description
xxx Description to be supplied.
Applies to
Examples
xxx Examples to be supplied.
See also
- charAt, lastIndexOf methods
italics method
Causes the calling string object to be italicized by surrounding it with HTML italics tags, <I> ... </I>.
Syntax
italics()
NOTE: For Beta4, use I() for this method.Description
xxx Description to be supplied.
Applies to
Examples
xxx Examples to be supplied.
See also
- blink, bold, strike methods
lastIndexOf method
Returns the index within the calling string object of the last occurrence of the specified character. The calling string is searched backwards, starting at fromIndex.
Syntax
indexOf(character, [fromIndex])
character is the character to search for.
fromIndex is the location within the calling string to start the search from, any integer from 0 to string.length() - 1.Description
xxx Description to be supplied.
Applies to
Examples
xxx Examples to be supplied.
See also
- charAt, indexOf methods
link method
Causes the calling string object to be a hyperlink by surrounding it with HTML hyperlink tags, <A HREF=...> </A>.
Syntax
link(location)
The argument to the method, location, should be a valid URL.Description
xxx Description to be supplied.
Applies to
Examples
xxx Examples to be supplied.
See also
- anchor method
log method
Returns the natural logarithm (base e) of its argument.
Syntax
log(arg)
Applies to
Examples
xxx Examples to be supplied.
See also
- exp method
max method
Returns the greater of its two arguments.
Syntax
max(arg1, arg2)
Applies to
Examples
xxx Examples to be supplied.
See also
- min method
min method
Returns the lesser of its two arguments.
Syntax
min(arg1, arg2)
Applies to
Examples
xxx Examples to be supplied.
See also
- max method
open method
For the window object, opens a new web browser window. xxx For the document object, description to be supplied.
Syntax
The first form of the syntax is for the document object; the second form is for window.
1. document.open("MIME type") 2. window.open("URL", "windowName", ["windowFeatures"])
URL specifies the URL to open in the new window.
windowName specifies a name for the window object being opened.
windowFeatures is a comma-separated list of any of the following options and values: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=pixels height=pixels
You may use any subset of these options. Separate options with a comma. Do not put spaces between the options.
pixels is a positive integer specifying the dimension in pixels.
NOTE: In event handlers, you must specify window.open() unless you want to call document.open() because of the scoping of static objects in JavaScript.
Description for window
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 URL argument specifies the URL contained by the new window. If URL is an empty string, a new, empty window is created.
windowFeatures is an optional, comma-separated list of options for the new window. The boolean windowFeatures options are set to true if they are specified without values, or as yes or 1. For example, open("", "messageWindow", "toolbar") and open("", "messageWindow", "toolbar=1") both set the toolbar option to true. If windowName does not specify an existing window and you do not specify windowFeatures, all boolean windowFeatures are true by default.
Following is a description of the windowFeatures:
- toolbar creates the standard Navigator toolbar, with buttons such as "Back" and "Forward", if true
- location creates a Location entry field, if true
- directories creates the standard Navigator directory buttons, such as "What's New" and "What's Cool", if true
- status creates the status bar at the bottom of the window, if true
- menubar creates the menu at the top of the window, if true
- scrollbars creates horizontal and vertical scrollbars when the document grows larger than the window dimensions, if true
- resizable allows a user to resize the window, if true
- copyhistory gives the new window the same session history as the current window, if true
- width specifies the width of the window in pixels
- height specifies the height of the window in pixels
Description for document
Description to be supplied.
Applies to
Examples
In the following example, the windowOpener function opens a window and uses write methods to display a message:
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>"); }
The following is an onClick event handler that opens a new client window displaying the content specified in the file sesame.html. It opens it with the specified option settings and names the corresponding window object newWin.
&lt;FORM NAME="myform"&gt; &lt;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')"&gt; &lt;/form&gt;
Notice the use of single quotes (') inside the onClick event handler.
See also
- close method
parse method
Syntax
Date.parse(date string)
Description
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.
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.
The parse function is a static method of Date. That means that you always use it as
Date.parse()
, rather than as a method of a date object you created.Applies to
Examples
If IPOdate is an existing date object, then
IPOdate.setTime(Date.parse("Aug 9, 1995"))
See also
- UTC method
pow method
Returns arg1 to the arg2 power, i.e. arg1arg2.
Syntax
pow(arg1, arg2)
Applies to
Examples
xxx Examples to be supplied.
See also
- sqrt method
prompt method
Displays an Prompt dialog box with a message and an input field
Syntax
prompt(message, input default)
Description
Use the prompt method to display a dialog box that takes user input. The arguments, message and input default are JavaScript values to be displayed as the message and the default value in the input field, respectively.
Applies to
Examples
prompt("Enter the number of doughnuts you want:", 12)
See also
- alert, confirm methods
random method
Returns a pseudo-random number between zero and one. xxx NYI.
Syntax
xxx To be supplied.
Applies to
Examples
xxx Examples to be supplied.
round method
Returns its argument, rounded to the nearest integer. In other words, if its argument is n.5 or greater (where n is an integer), returns n+1, otherwise returns n.
Syntax
round(arg)
Applies to
Examples
xxx Examples to be supplied.
select method
For password, text, and textArea, selects the input area of the object.
Syntax
select()
Description
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.
Applies to
Examples
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.
function checkPassword(userPass) { if (badPassword) { alert("Please enter your password again.") userPass.focus() userPass.select() } }
This example assumes that the password is defined as:<INPUT TYPE=password NAME=userPass>
See also
- blur, focus methods
setDate method
Syntax
dateObj.setDate(day)
where
dateObj
is a date object.Description
Sets the day of the month for the date object. The argument is an integer from 1 to 31.
Applies to
Examples
The second statement below changes the day for theBigDay to the 24th of July from its original value.
theBigDay = new Date("July 27, 1962 23:30:00") Xmas95.setDate(24)
See also
- xxx To be supplied.
setHours method
Syntax
dateObj.setHours(hours
where
dateObj
is a date object.Description
Sets the hours in the current time. The argument is an integer between 0 and 23.
Applies to
Examples
theBigDay.setHours(7)
See also
- xxx To be supplied.
setMinutes method
Syntax
dateObj.setMinutes(minutes)
where
dateObj
is a date object.Description
Sets the minutes in the current time. The argument is an integer between 0 and 59.
Applies to
Examples
theBigDay.setMinutes(45)
See also
- xxx To be supplied.
setMonth method
Syntax
dateObj.setMonth(month)
where
dateObj
is a date object.Description
Sets the month in the current date. The argument is an integer between 0 and 11.
Applies to
Examples
theBigDay.setMonth(6)
See also
- xxx To be supplied.
setSeconds method
Syntax
dateObj.setSeconds(seconds)
where
dateObj
is a date object.Description
Sets the seconds in the current time. The argument is an integer between 0 and 59.
Applies to
Examples
theBigDay.setSeconds(30)
See also
- xxx To be supplied.
setTime method
Syntax
dateObj.setTime(timevalue)
where
dateObj
is a date object.Description
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.
Applies to
Examples
theBigDay = new Date("July 1, 1999") sameAsBigDay = new Date(); sameAsBigDay.setTime(theBigDay.getTime())
setTimeout method
Evaluates an expression after a specified number of milliseconds have elapsed.
Syntax
timeoutID=setTimeout(expression, msec)
expression is a string expression.
msec is a numeric value or numeric string in millisecond units.
timeoutID is an identifier that is used only to cancel the evaluation with the clearTimeout method.Description
xxx Description to be supplied. Applies to
Examples
xxx Examples to be supplied.
See also
- clearTimeout
setYear method
Syntax
dateObj.setYear(year)
where
dateObj
is a date object.Description
Sets the year in the current date. Takes as its argument an integer greater than 1900.
Applies to
Examples
theBigDay.setYear(96)
See also
- xxx To be supplied.
sin method
Returns the sine of its argument. The argument is in radians.
Syntax
sin(arg)
Applies to
Examples
xxx Examples to be supplied.
See also
- acos, asin, atan, cos, tan methods
small method
Causes the calling string object to be displayed in small font by surrounding it with HTML small font tags, <SMALL>...</SMALL>.
Syntax
small()
Description
xxx Description to be supplied.
Applies to
Examples
xxx Examples to be supplied.
See also
- big, fontsize methods
sqrt method
Returns the square root of its argument.
Syntax
sqrt(arg)
Applies to
Examples
xxx Examples to be supplied.
See also
- pow method
strike method
Causes the calling string object to be displayed as struck out text, by surrounding it with HTML strikeout tags, <STRIKE> ... </STRIKE>.
Syntax
strike()
Description
xxx Description to be supplied.
Applies to
Examples
xxx Examples to be supplied.
See also
- blink, bold, italics methods
sub method
Causes the calling string object to be displayed as a subscript by surrounding it with HTML subscript tags, <SUB> ... </SUB>.
Syntax
sub()
Description
xxx Description to be supplied.
Applies to
Examples
xxx Examples to be supplied.
sup method
submit method
Submits the form.
Syntax
submit()
Description
xxx Description to be supplied.
Applies to
Examples
xxx Examples to be supplied.
substring method
The substring method returns a subset of a string object. If a < b, then it returns the subset starting at character a and ending before character b, considering the first character of the string to be character zero (0). If a > b, then it returns the subset starting at character b and ending at character a. If a = b, then it returns the empty string.
Syntax
substring(a, b)
Description
xxx Description to be supplied.
Applies to
Examples
If string x is "netscape" then x.substring(0,3) or x.substring(3,0) returns "net", and x.substring(4,7) or x.substring(7,4) returns "cap".
sup method
Causes the calling string object to be displayed as a superscript by surrounding it with HTML superscript tags, <SUP> ... </SUP>.
Syntax
sup()
Description
xxx Description to be supplied.
Applies to
Examples
xxx Examples to be supplied.
See also
- sub method
tan method
Returns the tangent of its argument. The argument is in radians.
Syntax
tan(arg)
Applies to
Examples
xxx Examples to be supplied.
See also
- acos, asin, atan, cos, sin methods
toGMTString method
Syntax
dateObj.toGMTString()
where
dateObj
is a date object.Description
Converts a date to a String, using the Internet GMT conventions.
Applies to
Examples
today.toGMTString()
If today is a date object, then toGMTString would convert the date to GMT (UTC) using the operating system's time zone offset, and return a string value in the following form:
Mon, 18 Dec 1995 17:28:35 GMT
toLocaleString method
Syntax
dateObj.toLocaleString()
where
dateObj
is a date object.Description
Converts a date to a String, using the locale conventions.
Applies to
Examples
today.toLocaleString()
If today is a date object, then toLocaleString will return a string value in the following form:
12/18/95 17:28:35
toLowerCase method
The toLowerCase method of string objects converts the string to all upper case.
Syntax
toLowerCase()
Description
xxx Description to be supplied.
Applies to
Examples
For example, "ALPHABET".toLowerCase yields "alphabet".
See also
- toUpperCase method
toString method
For location, returns location.href, so you can use location as a string without typing ".href". For Date, converts a date to a string.
Syntax
toString()
Description
xxx Description to be supplied.
Applies to
Examples
Here is an example of using toString with a date object, assuming theBigDay is a date object:
theBigDay.toString()
More Examples to be supplied.
toUpperCase method
The toUpperCase method of string objects converts the string to all upper case.
Syntax
toUpperCase()
Description
xxx Description to be supplied.
Applies to
Examples
For example, "alphabet".toUpperCase yields "ALPHABET".
See also
- toLowerCase method
UTC method
Syntax
Date.UTC(year, month, mday [, hrs] [, min] [, sec])
Description
UTC takes comma-delimited date parameters and returns the number of milliseconds since January 1, 1970 00:00:00, Universal Coordinated Time (GMT). The arameters are:
- year - a year after 1900
- month - a month between 0-11
- date - day of the month between 1-31
- hrs - hours between 0-23
- min - minutes between 0-59
- sec - seconds between 0-59
UTC is a static method of Date. That means that you always use it as
Date.UTC()
, rather than as a method of a date object you created.Applies to
Examples
The following statement creates a date object using GMT instead of local time:
gmtDate = new Date(Date.UTC(96, 11, 1, 0, 0, 0))
See also
- parse method
write method
Write HTML to the current window, in sequence with the HTML containing this SCRIPT. SCRIPTs have no effect on paragraphs or other structures in which they may occur.
Syntax
write()
Description
xxx Description to be supplied.
Applies to
Examples
xxx Examples to be supplied.
See also
- writeln method
writeln method
The same as write(), but adds a newline character. Note that this affects only preformatted text (inside a <PRE> or <XMP> tag).
Syntax
writeln()
Description
xxx Description to be supplied.
Applies to
Examples
xxx Examples to be supplied.
See also
- write method