0% found this document useful (0 votes)
74 views

JavaScript Methods and Functions PDF

This document provides summaries of common JavaScript methods and functions, including: - Math.abs() returns the absolute value of a number - alert() displays an alert dialog box - anchor() creates an HTML anchor tag - history.back() returns to the previous URL - string.big() displays a string in large print
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views

JavaScript Methods and Functions PDF

This document provides summaries of common JavaScript methods and functions, including: - Math.abs() returns the absolute value of a number - alert() displays an alert dialog box - anchor() creates an HTML anchor tag - history.back() returns to the previous URL - string.big() displays a string in large print
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

13/2/2020 JavaScript Methods and Functions

JavaScript Methods and Functions


Natalia Beltikova, Irina Kuzina (RRC "Kurchatov Institute")

abs forward setDate


acos getDate setHours
alert getDay setMinutes
anchor getHours setMonth
asin getMinures setSeconds
atan getMonth setTime
back getSeconds setTimeout
big getTime setYear
blink getTimezoneOffset sin
blur getYear small
bold go sqrt
ceil indexOf strike
charAt isNaN sub
clearTimeout italics submit
click lastIndexOf substring
close (document object) link sup
close (window object) log tan
confirm max toGMTString
cos min
escape open (document object) toLowerCase
eval open (window object) toUpperCase
exp parse unescape
fixed parseFloat UTC
floor parseInt write
focus pow writeln
fontcolor prompt
fontsize random
file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 1/50
13/2/2020 JavaScript Methods and Functions

Abs method
Returns the absolute value of a number.

Syntax:

Math.abs ( number )

number is any numeric expression or property of an existing object.

Method:

Math

Acos method

Returns the arccosine of a number (in radians).

Syntax:

Math.acos ( number )

number is a numeric expression between -1 and 1 or a property of an existing object.

Method:

Math

Description:

The acos method returns a numeric value between 0 and pi. If number is outside this range, the return value will always be 0.

See also:

asin , atan , cos , sin, and tan methods .

file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 2/50


13/2/2020 JavaScript Methods and Functions

Alert method

Displays an Alert dialog box with a message and an OK button.

Syntax:

alert (" message ")

Method:

window

Description:

The alert method is used to display a message that does not require a user's decision. The message argument specifies the message that contains the
dialog box.
Although alert is a method of the window object, you do not need to define windowReference when it is called. For example, windowReference .alert
() is optional.

See also:

confirm , prompt methods .

Anchor method
Creates an HTML anchor that is used as a hypertext link.

Syntax:

text .anchor ( nameAttribute )

text any string or property of an existing object.


nameAttribute any string or property of an existing object.

Method:

string
file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 3/50
13/2/2020 JavaScript Methods and Functions

Description:

The anchor method is used with the write or writeln methods to programmatically create and display anchors in a document. An anchor is created
using the anchor method, and write or writeln is used to display the anchor in the document.
In the syntax, the string text is the text that the user sees. The nameAttribute string is the NAME attribute of the <A> tag.
Anchors created using the anchor method become elements of the anchors array. See the anchor object for information on the anchors array .

See also:

link method

Asin method
Returns the arcsine of a number (in radians).

Syntax:

Math.asin ( number )

number is a numeric expression between -1 and 1 or a property of an existing object.

Method:

Math

Description:

The asin method returns a numeric value between -PI / 2 and Pi / 2. If number is outside this range, the return value will always be 0.

See also:

methods acos , atan , cos , sin , tan .

Atan method

Returns the arc tangent of a number (in radians).

file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 4/50


13/2/2020 JavaScript Methods and Functions

Syntax:

Math.atan ( number )

number is any numerical expression or property of an existing object that represents the tangent of an angle.

Method:

Math

Description:

The atan method returns a numeric expression between -PI / 2 and Pi / 2.

See also:

methods acos , asin , cos , sin , tan .

Back method
Allows you to return to the previous URL in the list of visited URLs.

Syntax:

history.back ()

Method:

history

Description:

This method performs an action equivalent to the user choosing the Back button in the Navigator window. The back method is also equivalent to
history.go (-1).

See also:

file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 5/50


13/2/2020 JavaScript Methods and Functions

forward , go methods .

Big method
Invokes a string displayed in large print, as if setting the <BIG> tag to it.

Syntax:

stringName .big ()

stringName is any string or property of an existing object.

Method:

string

Description:

To format and display a string in a document, the big method is used with the write or writeln methods.

See also:

methods fontsize , small .

Blink method

Causes a blinking line, as if setting the <BLINK> tag to it.

Syntax:

stringName .blink ()

stringName is any string or property of an existing object.

Method:

string
file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 6/50
13/2/2020 JavaScript Methods and Functions

Description:

To format and display a string in a document, the blink method is used with the write or writeln methods.

See also:

methods bold , italics , strike .

Blur method
Changed in Navigator 3.0.
Removes focus from the specified subject.

Syntax:

1. password .blur ()

2. select .blur ()

3. textName .blur ()

4. textareaName .blur ()

password any value of the NAME attribute of the password object or an element of the elements array .
select any value of the NAME attribute of the select object or element of the elements array .
textName is any value of the NAME attribute of the text object or an element of the elements array .
textareaName any value of the NAME attribute of the textarea object or an element of the elements array .

Method:

password , select, text , textarea .

Description:

The blur method is used to remove focus from the specified form element.

See also:

focus , select methods .


file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 7/50
13/2/2020 JavaScript Methods and Functions

Bold method

Invokes a line displayed in bold, as if setting the <B> tag to it.

Syntax:

stringName .bold ()

stringName is any string or property of an existing object.

Method:

string

Description:

To format and display a string in a document, the bold method is used with the write or writeln methods.

See also:

blink , italics , strike methods .

Ceil method
Returns the nearest integer of a number, rounded up or equal to a number.

Syntax:

Math.ceil ( number )

number is any numeric expression or property of an existing object.

Method:

Math

file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 8/50


13/2/2020 JavaScript Methods and Functions

See also:

floor method .

CharAt method

Returns the character specified in index .

Syntax:

stringName .charAt ( index )

stringName is any string or property of an existing object.


index is any integer from 0 to stringName .length-1 or a property of an existing object.

Method:

string

Description:

Characters in a string are indexed from left to right. The index of the first character is 0, the index of the last character is stringName .length-1. If you
specify index greater than the number of characters in the string, JavaScript will return an empty string.

See also:

methods indexOf , lastindexOf .

ClearTimeout method
The end of the delay set by the setTimeout method.

Syntax:

clearTimeout ( timeoutID )

timeoutID The delay whose setting was returned by a previous call to the setTimeout method.
file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 9/50
13/2/2020 JavaScript Methods and Functions

Method:

frame , window

Description:

See the description of the setTimeout method

See also:

method setTimeout

Click method

Simulates a mouse click on a selected form element.

Syntax:

1. buttonName .click ()

2. radioName [ index ] .click ()

3. checkboxName .click ()

buttonName any value of the NAME attribute of button, reset, or submit objects or an element of the elements array .
radioName value of the NAME attribute of the radio object or element of the elements array .
index is an integer representing the radio button in the radio object.
checkboxName any value of the NAME attribute of the checkbox object or an element of the elements array .

Method:

button , checkbox , radio , reset , submit .

Description:

The result of the click method changes depending on the element being called:

file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 10/50


13/2/2020 JavaScript Methods and Functions

for button, reset and submit, the same action is performed - pressing a button.
for radio - select the radio button.
for checkbox - checkmark the checkbox and set the value to on.

Close method (document object)


Closes the output stream and completes the data output to the Navigator workspace for display.

Syntax:

document.close ()

Method:

document

Description:

The close method closes the output stream opened by the document.open () method. If the stream was opened for the Navigator workspace, the close
method completes the output of the stream to the screen. Font style tags, such as <BIG> and <CENTER>, automatically close the output stream. The
close method also stops the "meteor shower" in the Navigator icon and displays "Document: Done" in the status bar.

See also:

methods open , write , writeln .

Close method (window object)

Changed in Navigator 3.0.


Closes the specified window.

Syntax:

windowReference .close ()

windowReference is a reference to the window, as described in the window object .

file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 11/50


13/2/2020 JavaScript Methods and Functions

Method:

window

Description:

The close method closes the specified window. If you declare close without specifying windowReference , then JavaScript closes the current window.
In events, you should specify window.close () instead of the commonly used close (). Declaring close () without specifying an object name is
equivalent to document.close ().

See also:

open method

Confirm method

Displays a dialog box with the specified message and the OK and Cancel buttons.

Syntax:

confirm (" message ")

message any string or property of an existing object.

Method:

window

Description:

The confirm method is used to make a decision by the user that requires either OK or Cancel. The message argument defines a message that requires a
user decision. The confirm method returns true if the user selected OK, and false if the user selected Cancel.
Although confirm is a method of the window object, you do not need to specify windowReference when it is called. For example, windowReference
.confirm () is optional.

See also:

alert , prompt methods


file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 12/50
13/2/2020 JavaScript Methods and Functions

Cos method

Returns the cosine of a number.

Syntax:

Math.cos ( number )

number is a numeric expression representing the size of an angle in radians or a property of an existing object.

Method:

Math

Description:

The cos method returns a numeric value between -1 and 1, which is the cosine of the angle.

See also:

methods acos , asin , atan , sin , tan .

Escape function
Returns the ASCII value of an argument encoded in ISO Latin-1.

Syntax:

escape (" string ")

string is not an alphanumeric string in ISO Latin-1 encoding or a property of an existing object.

Description:

The escape function is not a method associated with any object, but is part of the language itself.
The value returned by the escape function is a string of the form "% xx", where xx is the ASCII character encoding of the argument. If the argument to
the escape function is an alphanumeric character, then the escape function returns the same character.
file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 13/50
13/2/2020 JavaScript Methods and Functions

See also:

unescape function .

Eval function

The eval function executes the argument string and substitutes the resulting value in its place.

Syntax:

eval (" string ")

string any string representing a JavaScript expression, command, or sequence of commands. An expression can include variables and properties of an
existing object.

Description:

The eval function is a built-in JavaScript function. It is not a method associated with any object, but it is part of the language itself.
The argument to the eval function is a string. Do not use eval to calculate arithmetic expressions. JavaScript calculates arithmetic expressions
automatically. If the argument is an expression, eval evaluates the expression. If the argument is one or more JavaScript commands, then eval
executes the commands.
If you built an arithmetic expression as a string, you can use eval to evaluate it.

Exp method

Returns e number , where number is the argument, and e is the exponent, the base of the natural logarithm.

Syntax:

Math.exp ( number )

number is any numeric expression or property of an existing object.

Method:

Math

file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 14/50


13/2/2020 JavaScript Methods and Functions

See also:

log , pow methods .

Fixed method

Invokes a string displayed in a monospaced font, as if setting the <TT> tag to it.

Syntax:

stringName .fixed ()

stringName is any string or property of an existing object.

Method:

string

Description:

To format and display a string in a document, the fixed method is used with the write and writeln methods.

Floor method

Returns the nearest integer of a number rounded down or equal to a number.

Syntax:

Math.floor ( number )

number is any numeric expression or property of an existing object.

Method:

Math

file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 15/50


13/2/2020 JavaScript Methods and Functions

See also:

ceil method .

Focus method

Changed in Navigator 3.0.


Sets focus to a specific subject.

Syntax:

1. password .focus ()

2. select .focus ()

3. textName .focus ()

4. textareaName .focus ()

password any value of the NAME attribute of the password object or an element of the elements array .
select any value of the NAME attribute of the select object or element of the elements array .
textName is any value of the NAME attribute of the text object or an element of the elements array .
textareaName any value of the NAME attribute of the textarea object or an element of the elements array .

Method:

password , select, text , textarea .

Description:

The focus method is used to set focus on the specified form element. You can then programmatically enter a value in an element or let the user enter a
value.

See also:

blur , select methods .

Fontcolor method

file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 16/50


13/2/2020 JavaScript Methods and Functions

Invokes the line displayed in the set color, as if placing it in the <FONT COLOR = color > tag.

Syntax:

stringName .fontcolor ( color )

stringName is any string or property of an existing object.


color is a string or property of an existing object that defines color as a six-digit hexadecimal number (RGB) or as one of the string names in the
Color Value list.

Method:

string

Description:

To format and display a string in a document, the fontcolor method is used with the write and writeln methods.
If you define color as a six-digit hexadecimal number, you must use the rrggbb format.
The fontcolor method invalidates the value set in the fgColor property.

Fontsize method

Invokes the string displayed by the set font size, as if placing it in the <FONT SIZE = size > tag.

Syntax:

stringName .fontsize ( size )

stringName is any string or property of an existing object.


size an integer from 1 to 7 or a string representing a signed integer (+ or -) from 1 to 7, or a property of an existing object.

Description:

To format and display a string in a document, the fontsize method is used with the write and writeln methods.
When you define size as an integer, you set the size of stringName to one of the seven specified sizes. When you define size as "-2", you set the font
size of stringName relative to the size set in the tag.

See also:
file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 17/50
13/2/2020 JavaScript Methods and Functions

methods big , small .

Forward method
Loads the following URL in the list of visited URLs.

Syntax:

history.forward ()

Method:

history

Description:

This method performs an action equivalent to the user choosing the Forward button in the Navigator window. The forward method is also equivalent
to history.go (1).

See also:

back , go methods .

GetDate Method

Returns the day of the month for the specified date.

Syntax:

dateObjectName .getDate ()

dateObjectName is any date object name or property of an existing object.

Method:

Date

file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 18/50


13/2/2020 JavaScript Methods and Functions

Description:

The value returned by getDate is an integer from 1 to 31.

See also:

setDate method

GetDay method
Returns the day of the week for the specified date.

Syntax:

dateObjectName .getDay ()

dateObjectName is any date object name or property of an existing object.

Method:

Date

Description:

The value returned by getDay is an integer corresponding to the day of the week: zero for Sunday, one for Monday, two for Tuesday, and so on.

GetHours method
Returns the clock for the specified date.

Syntax:

dateObjectName .getHours ()

dateObjectName is any date object name or property of an existing object.

Method:
file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 19/50
13/2/2020 JavaScript Methods and Functions

Date

Description:

The value returned by getHours is an integer from 0 to 23.

See also:

setHours method .

GetMinutes method

Returns the minutes for the specified date.

Syntax:

dateObjectName .getMinutes ()

dateObjectName is any date object name or property of an existing object.

Method:

Date

Description:

The value returned by getMinutes is an integer from 0 to 59.

See also:

method setMinutes .

GetMonth method

Returns the month for the specified date.

Syntax:

file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 20/50


13/2/2020 JavaScript Methods and Functions
dateObjectName .getMonth ()

dateObjectName is any date object name or property of an existing object.

Method:

Date

Description:

The value returned by getMonth is an integer from 0 to 11. Zero corresponds to January, one to February, and so on.

See also:

method setMonth .

GetSeconds method

Returns seconds in the current time.

Syntax:

dateObjectName .getSeconds ()

dateObjectName is any date object name or property of an existing object.

Method:

Date

Description:

The value returned by getSeconds is an integer from 0 to 59.

See also:

method setSeconds .
file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 21/50
13/2/2020 JavaScript Methods and Functions

GetTime method

Returns a numeric value corresponding to the time for the specified date.

Syntax:

dateObjectName .getTime ()

dateObjectName is any date object name or property of an existing object.

Method:

Date

Description:

The value returned by the getTime method is the number of milliseconds since January 1, 1970, 00:00:00. You can use this method to assign the date
and time to another date object.

See also:

method setTime .

GetTimezoneOffset method
Returns the time zone offset in minutes relative to the Greenwich meridian.

Syntax:

dateObjectName .getTimezoneOffset ()

dateObjectName is any date object name or property of an existing object.

Method:

Date

file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 22/50


13/2/2020 JavaScript Methods and Functions

Description:

The time zone offset is the difference between local time and GMT (Greenwich Mean Time). Seasonal time (winter, summer) does not make it
possible to talk about this shift as a constant.

GetYear method

Returns the year for the specified date.

Syntax:

dateObjectName .getYear ()

dateObjectName is any date object name or property of an existing object.

Method:

Date

Description:

The value returned by getYear is equal to the year minus 1900. For example, if the year is 1976, then the return value is 76.

See also:

method setYear .

Go method
Loads a URL from the list of visited URLs.

Syntax:

history.go ( delta | location )

delta is an integer or property of an existing object that represents a relative position in the list of visited URLs.
location is a string or property of an existing object, which is a URL or part of it from the list of visited URLs.
file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 23/50
13/2/2020 JavaScript Methods and Functions

Method:

history

Description:

The go method allows you to go to the address contained in the list of visited URLs, which you specified as an argument to the go method. You can
view this list by selecting History from the Window menu. The last 10 list items are also displayed on the Go menu.
The delta argument can be a positive or negative number. If delta is greater than zero, then the go method jumps forward in the list of visited URLs;
otherwise, you go back to the URL. If delta is 0, then Navigator reloads the current page.
The location argument is a string. location selects the closest URL in the list of visited URLs containing the substring location to downloadthat you
specified as an argument. Each part of the URL contains specific information. See the location object for URL components.

See also:

back , forward methods .

IndexOf method

Returns the index of the position of the first encountered search value in the called string object. Search begins with fromIndex .

syntax:

stringName .indexOf ( searchValue, [fromIndex] )

stringName is any string or property of an existing object.


searchValue is a string or property of an existing object that represents the search value.
fromIndex the place in the called line from which the search begins. It can be any integer from 0 to stringName .length-1 or a property of an existing
object.

Method:

string

Description:

Characters in a string are indexed from left to right. The index of the first character is 0, the index of the last is stringName .length-1.
If you do not specify a value fromIndex , JavaScript defaults to 0. If searchValue is not found, JavaScript returns -1.
file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 24/50
13/2/2020 JavaScript Methods and Functions

See also:

methods charAt , lastIndexOf .

IsNaN function

Changed in Navigator 3.0.


On UNIX platforms, checks if it is "NaN" (not a number).

Syntax:

isNaN ( testValue )

testValue is the value you want to test.

Description:

The isNaN function is a built-in JavaScript function. It is not a method associated with any object, but it is part of the language itself. The isNaN
function is used only on UNIX platforms.
On all platforms except Windows, the parseFloat and parseInt functions return "NaN" when they accept a non-numeric value. The value of "NaN" is
not a number in any way. You can call the NaN function to determine if the result is parseFloat or parseInt "NaN". If arithmetic operations are
performed on "NaN", then their results will also be "NaN".
The isNaN function returns true or false.

See also:

functions parseFloat , parseInt .

Italics method

Invokes a line displayed in italics, as if setting the <I> tag to it.

Syntax:

stringName .italics ()

stringName is any string or property of an existing object.

file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 25/50


13/2/2020 JavaScript Methods and Functions

Method:

string

Description:

To format and display a string in a document, the italics method is used with the write or writeln methods.

See also:

blink , bold , strike methods .

LastIndexOf Method

Returns the index of the first encountered search value in the called string object. Search by string is performed in the opposite direction, starting from
fromIndex .

Syntax:

stringName .lastindexOf ( searchValue, [fromIndex] )

stringName is any string or property of an existing object.


searchValue is a string or property of an existing object that represents the search value.
fromIndex the place in the called line from which the search begins. It can be any integer from 0 to stringName .length-1 or a property of an existing
object.

Method:

string

Description:

Characters in a string are indexed from left to right. The index of the first character is 0, the index of the last is stringName .length-1.
If you do not specify a value fromIndex , JavaScript defaults to stringName .length-1 (end of line). If searchValue is not found, JavaScript returns -1.

See also:

methods charAt , IndexOf .


file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 26/50
13/2/2020 JavaScript Methods and Functions

Link method

Creates an HTML hypertext link where you can go to another URL.

Syntax:

linkText .link ( hrefAttribute )

Method:

string

Description:

To create and display a hypertext link in a document, the link method is used with the write or writeln methods. Create a link using the link method,
then call write or writeln to display the link in the document.
In the syntax, the linkText string is the text that the user sees. The hrefAttribute string represents the HREF attribute of the <A> tag, this will be the
destination URL. Each part of the URL contains specific information. See the location object for URL components.
Links created by the link method become elements of the links array .

See also:

anchor method .

Log method
Returns the natural logarithm of a number (base e ).

Syntax:

Math.log ( number )

number is any positive numeric expression or property of an existing object.

Method:

Math
file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 27/50
13/2/2020 JavaScript Methods and Functions

Description:

If number is out of range, the returned value will always be -1.797693134862316e + 308.

See also:

exp , pow methods .

Max method
Returns the larger number of two.

Syntax:

Math.max ( number1, number2 )

number1 and number2 are any numeric arguments or properties of existing objects.

Method:

Math

See also:

min method .

Min method
Returns the smaller of two.

Syntax:

Math.min ( number1, number2 )

number1 and number2 are any numeric arguments or properties of existing objects.

Method:
file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 28/50
13/2/2020 JavaScript Methods and Functions

Math

See also:

method max .

Open method (document object)

Opens a stream to receive output using write and writeln methods.

Syntax:

document.open ([" mimeType "])

mimeType sets any of the following document types:


text / html

text / plain

image / gif

image / jpeg

image / x-bitmap

plug-in

plug-in any composite MIME plug-in type supported by Netscape.

Method:

document

Description:

The open method opens a stream for receiving output using the write and writeln methods. If mimeType is text or a picture, then the stream is open in
the Navigator workspace; otherwise, the stream is open on the plug-in. If the document already exists in the target window, then the open method
clears it.
To close the stream, use the document.close () method. The close method calls the text or image that was sent to the Navigator workspace for display.
file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 29/50
13/2/2020 JavaScript Methods and Functions

After using document.close (), enter document.open () again when you want to start outputting another stream.
mimeType is an optional argument specifying the type of document. If you do not specify mimeType , then the open method accepts text / html by
default. MimeType
Description:

text / html defines text containing ASCII text in HTML format.


text / plain defines text containing ASCII text with end-of-line characters to limit the display of lines.
image / gif defines a document with encoded bytes containing a GIF header and pixel sizes.
image / jpeg defines a document with encoded bytes containing a JPEG header and pixel sizes.
image / x-bitmap defines a document with encoded bytes containing a bitmap header and pixel sizes.
plug-in loads a specific plug-in and uses it as a destination for the write and writeln methods. For example, x-world / vrtml downloads the VR
Scout VRML plug-in from Chaco Communications, and aplication / x-director downloads the Macromedia Shockware plug-in.

See also:

methods close , write , writeln .

Open method (window object)

Opens a new web browser window.

Syntax:

[ windowVar = ] [window] .open ( "URL", "windowName", ["windowFeatures"] )

windowVar is the name of the new window. This variable is used when referring to properties, methods, and containers of a window.
URL defines the URL that opens in a new window. See the location object for URL components.
windowName is the window name used in the TARGET attribute of the <FORM> or <A> tag. windowName can contain only alphanumeric characters
or underscores (_).
windowFeatures a comma-separated list of any of the following options or values:
toolbar [= yes | no] | [= 1 | 0]

location [= yes | no] | [= 1 | 0]

directoties [= yes | no] | [= 1 | 0]

status [= yes | no] | [= 1 | 0]

menubar [= yes | no] | [= 1 | 0]

file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 30/50


13/2/2020 JavaScript Methods and Functions

scrollbars [= yes | no] | [= 1 | 0]

resizable [= yes | no] | [= 1 | 0]

width = pixels

height = pixels

You can use any set of these options. Options are separated by a comma. Do not space between options.
pixels is a positive integer specifying the size of the window in pixels.

Method:

window

Description:

The open method opens a new window for the client’s web browser, which is equivalent to selecting New WebBrowser from the File Navigator menu.
The URL argument specifies the URL contained in the new window. If the URL is an empty string, an empty window will be created.
In events, you should specify window.open () instead of the commonly used open (). Declaring open () without specifying an object name is
equivalent to document.open ().
windowFeatures is an optional comma-separated list of options for a new window. Boolean options windowFeatures take true if they are defined
without values, or as yes or 1. For example, open ("", "messageWindow", "toolbar") and open ("", "messageWindow", "toolbar = 1") as in the first ,
and in the second case, the toolbar option is true. If windowName does not define an existing window and you do not define windowFeatures , then all
boolean options of windowFeatures default to true. If you specify any of the windowFeatures options , then all other options are set to false unless
you specify them additionally.
Description of windowFeatures :

toolbar creates standard Navigator work tools, with buttons such as "Back" and "Forward".
location creates the Location input field.
directories creates buttons for standard Navigator directories, such as "What's New" and "What's Coll".
status creates a status bar at the bottom of the window.
menubar creates a menu at the top of the window.
scrollbars creates horizontal and vertical scrolls when the document is larger than the size of the window.
resizable allows the user to resize the window.
width defines the width of the window in pixels.
height determines the height of the window in pixels.

See also:

file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 31/50


13/2/2020 JavaScript Methods and Functions

close method .

Parse method
Returns the number of milliseconds in a string representation of a date starting January 1, 1970, 00:00:00, local time.

Syntax:

Date.parse ( dateString )

Method:

Date

Description:

The parse method returns a date in a string representation (for example, "Dec 25, 1995") and returns the number of milliseconds since January 1,
1970, 00:00:00 (local time). This function is used to set date values based on a string value, for example, in combination with the setTime method and
the Date object.
The resulting string represents time, parse returns the time value. It is accepted in the standard IETF date syntax: "Mon, 25 Dec 1995 13:30:00 GMT."
She understands the US continental time zone, but mainly uses the time offset zone, for example, "Mon, 25 Dec 1995 13:30:00 GMT + 0430" (4
hours, 30 minutes west of Greenwich). If you do not specify a time zone, the local time zone is accepted. GMT and UTC are considered equivalent.
Since the parse function is a static Date method, you always use it as Date.parse (), and not as a method of the date object you created.

See also:

UTC method

ParseFloat Function

Parses a string argument and returns a floating-point number.

Syntax:

parseFloat ( string )

string A string representing the value you want to parse.


file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 32/50
13/2/2020 JavaScript Methods and Functions

Description:

The parseFloat function is an inline JavaScript object. It is not a method associated with any object, but it is part of the language itself.
The parseFloat function parses the argument string and returns a floating-point number. If the character he encounters differs from the sign (+ or -),
digit (0-9), decimal point or exponent, then he returns the value to this point, ignoring this character and all subsequent characters.
If the first character cannot be converted to a number, parseFloat returns one of the following values:

"empty" on Windows platforms.


"NaN" on any other platform indicates that the value is not a number.

See also:

methods isNaN , parseInt .

ParseInt function
Parses a string argument and returns an integer defined as a base.

Syntax:

parseInt ( string [, radix] )

string is a string that represents the value you want to parse.


radix is an integer representing the base of the return value.

Description:

The parseFloat function is an inline JavaScript object. It is not a method associated with any object, but it is part of the language itself.
The parseFloat function parses its first string argument and tries to return an integer defined as a base. For example, base 10 means a decimal, 8 is an
octal, 16 is a hexadecimal, and so on.
If parseInt encounters a character that is not a number at the specified base, then it skips it and all the following characters and returns an integer value
parsed to a point. ParseInt truncates numbers to integer values.
If the base is not defined or defined as 0, JavaScript accepts the following:

if the string entry starts with "0x", then the base is 16 (hexadecimal).
if the string entry starts with "0", then the base is 8 (octal).
if the string entry starts with any other value, then the base is 10 (decimal).
if the first character cannot be converted to a number, parseFloat returns one of the following values:
"empty" on Windows platforms.
file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 33/50
13/2/2020 JavaScript Methods and Functions

"NaN" on any other platform indicates that the value is not a number.

For arithmetic purposes, the value "NaN" is not a number in any case. You can call the isNaN function to determine if the result of parseInt is "NaN".
If "NaN" is used in arithmetic operations, then their results will also be "NaN".

See also:

functions isNaN , parseFloat .

Pow method

Returns base in exponent degree , i.e. base exponent .

Syntax:

Math.pow ( base, exponent )

base is a numeric expression or property of an existing object.


exponent a numeric expression or property of an existing object. If the result may turn out to be an invalid value (for example, pow (-1, 0.5), then the
returned value is zero.

Method:

Math

See also:

exp , log methods .

Prompt method

Displays a dialog box with a message and input field.

Syntax:

prompt ( message, [inputDefault] )

file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 34/50


13/2/2020 JavaScript Methods and Functions

message any string or property of an existing object; the line is displayed as a message.
inputDefault is a string, integer, or property of an existing object that represents the value that is entered in the default field.

Method:

window

Description:

The prompt method is used to display a dialog box that requires user input. If you do not specify an initial value for inputDefault , the dialog box
displays the value <undefined>.
Although prompt is a method of the window object, you do not need to define windowReference when it is called. For example, windowReference
.prompt () is optional.

See also:

alert , confirm methods .

Random method

Changed in Navigator 3.0.


Returns a random number between zero and one. This method is used only on UNIX platforms.

Syntax:

Math.random ()

Method:

Math

SetDate method

Sets the day of the month for the specified date.

Syntax:

file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 35/50


13/2/2020 JavaScript Methods and Functions

dateObjectName .setDate ( dayValue )

dateObjectName is any date object name or property of an existing object.


dayValue is an integer from 1 to 31 or a property of an existing object, which is the day of the month.

Method:

Date

See also:

getDate method .

SetHours method

Sets the clock for the specified date.

Syntax:

dateObjectName .setHours ( hoursValue )

dateObjectName is any date object name or property of an existing object.


hoursValue is an integer from 0 to 23 or a property of an existing object, which is a clock.

Method:

Date

See also:

getHours method .

SetMinutes method

Sets the minutes for the specified date.

Syntax:
file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 36/50
13/2/2020 JavaScript Methods and Functions

dateObjectName .setMinutes ( minutesValue )

dateObjectName is any date object name or property of an existing object.


minutesValue is an integer from 0 to 59 or a property of an existing object that represents minutes.

Method:

Date

See also:

getMinutes method .

SetMonth method

Sets the month for the specified date.

Syntax:

dateObjectName .setMonth ( month Value )

dateObjectName is any date object name or property of an existing object.


monthValue is an integer from 0 to 11 (representing the months of January to December) or a property of an existing object.

Method:

Date

See also:

getMonth method .

SetSeconds method

Sets the seconds for the specified date.

Syntax:
file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 37/50
13/2/2020 JavaScript Methods and Functions

dateObjectName .setSeconds ( secondsValue )

dateObjectName is any date object name or property of an existing object.


secondsValue is an integer from 0 to 59 or a property of an existing object.

Method:

Date

See also:

getSeconds method .

SetTime method

Sets the value of a date object.

Syntax:

dateObjectName .setTime ( timevalue )

dateObjectName is any date object name or property of an existing object.


timevalue is an integer or property of an existing object, representing the number of milliseconds since January 1, 1970, 00:00:00.

Method:

Date

Description:

The setTime method is used to add the date and time to another object.

See also:

getTime method .

SetTimeout method
file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 38/50
13/2/2020 JavaScript Methods and Functions

Executes an expression after the specified number of milliseconds has passed.

Syntax:

timeoutID = setTimeout ( expression, msec )

timeoutID is an identifier that is used only to complete execution using the clearTimeout method.
expression string expression or property of an existing object.
msec numeric value, number series, or property of an existing object in milliseconds.

Method:

frame , window

Description:

The setTimeout method executes an expression after a set amount of time. It does not execute the expression multiple times. For example, if the
setTimeout method is set to 5 seconds, then the expression will be executed after 5 seconds, but not every 5 seconds.

See also:

clearTimeout method .

SetYear method

Sets the year for the specified date.

Syntax:

dateObjectName .setYear ( yearValue )

dateObjectName is any date object name or property of an existing object.


timevalue integer greater than 1900 or a property of an existing object.

Method:

Date

file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 39/50


13/2/2020 JavaScript Methods and Functions

See also:

getYear method .

Sin method

Returns the sine of a number.

Syntax:

Math.sin ( number )

number is a numeric expression or property of an existing object, which is the value of the angle in radians.

Method:

Math

Description:

The sin method returns a numeric value between -1 and 1, which is the sine of the angle.

See also:

methods acos , asin , atan , cos , tan .

Small method
Displays a line in small print, as if setting the <SMALL> tag to it.

Syntax:

stringName .small ()

stringName is any string or property of an existing object.

Method:
file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 40/50
13/2/2020 JavaScript Methods and Functions

string

Description:

To format and display a string in a document, the small method is used with the write or writeln methods.

See also:

methods big , fontsize .

Sqrt method

Returns the square root of a number.

Syntax:

Math.sqrt ( number )

number is any non-negative numeric expression or property of an existing object.

Method:

Math

Description:

If number is outside this range, the returned value will always be 0.

Strike method

Displays a line displayed as strikethrough text, as if setting the <STRIKE> tag to it.

Syntax:

stringName .strike ()

file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 41/50


13/2/2020 JavaScript Methods and Functions

stringName is any string or property of an existing object.

Method:

string

Description:

To format and display a string in a document, the strike method is used with the write or writeln methods.

See also:

Methods blink , bold , the italics .

Sub method

Displays a string displayed as a subscript, as if setting the <SUB> tag to it.

Syntax:

stringName .sub ()

stringName is any string or property of an existing object.

Method:

string

Description:

To format and display a string in a document, the sub method is used with the write or writeln methods.

See also:

sup methods .

file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 42/50


13/2/2020 JavaScript Methods and Functions

Submit method

Submits a form.

Syntax:

formName .submit ()

formName is any string or property of an existing object.

Method:

form

Description:

The submit method submits the specified form. It performs the same action as the submit button.
The submit method is used to send data to the http server. The submit method returns data using the get or post methods defined in the method
property.

See also:

submit object .
property onSubmit.

Substring method
Returns the substring of a string object.

Syntax:

stringName .substring ( indexA, indexB )

stringName is any string or property of an existing object.


indexA is any integer from 0 to stringName .length-1 or a property of an existing object.
indexB is any integer from 0 to stringName .length-1 or a property of an existing object.

file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 43/50


13/2/2020 JavaScript Methods and Functions

Method:

string

Description:

Characters in a string are indexed from left to right. The index of the first character is 0, the index of the last is stringName .length-1.
If indexA is less than indexB , then the substring method returns a substring, starting with the character indexA and ending with the character before
indexB . If indexA is greater than indexB , then the substring method returns a substring, starting with the character indexB and ending with the
character before indexA . If indexA is equal to indexB , then the substring method returns an empty string.

Sup method
Displays a string displayed as a subscript, as if setting the <SUP> tag to it.

Syntax:

stringName .sup ()

stringName is any string or property of an existing object.

Method:

string

Description:

To format and display a string in a document, the sup method is used with the write or writeln methods.

See also:

sub methods .

Tan method

Returns the tangent of a number.

file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 44/50


13/2/2020 JavaScript Methods and Functions

Syntax:

Math.tan ( number )

number is a numeric expression representing the value of the angle in radians, or a property of an existing object.

Method:

Math

Description:

The tan method returns a numeric value that represents the tangent of an angle.

See also:

methods acos , asin , atan , cos , sin .

ToGMTString method
Converts a date to a string using Greenwich Mean Time (GMT).

Syntax:

dateObjectName .toGMTString ()

dateObjectName is any date object name or property of an existing object.

Method:

Date

Description:

The exact format of the return value of toGMTString is platform dependent.

See also:
file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 45/50
13/2/2020 JavaScript Methods and Functions

toLocaleString methods .

ToLocaleString method
Converts a date to a string using the local time zone.

Syntax:

dateObjectName .toLocaleString ()

dateObjectName is any date object name or property of an existing object.

Method:

Date

Description:

If you use toLocaleString to translate the date, remember that different locales collect the string in different ways. Use the getHours, getMinutes,
getSeconds methods to get more portable results.

See also:

toGMTString methods .

ToLowerCase method

Returns the value of the called string converted to lowercase.

Syntax:

stringName .toLowerCase ()

stringName is any string or property of an existing object.

Method:

file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 46/50


13/2/2020 JavaScript Methods and Functions

string

Description:

The toLowerCase method returns stringName converted to lowercase. toLowerCase does not change the value of stringName .

See also:

toUpperCase methods .

ToUpperCase method

Returns the value of the called string converted to uppercase.

Syntax:

stringName .toUpperCase ()

stringName is any string or property of an existing object.

Method:

string

Description:

The toUpperCase method returns the stringName value , converted to uppercase. toUpperCase does not change the value of stringName .

See also:

toLowerCase methods .

Unescape function

Returns an ASCII string for the specified value.

Syntax:

file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 47/50


13/2/2020 JavaScript Methods and Functions

unescape (" string ")

string A string or property of an existing object that contains characters in any of the following forms:

"% integer" , where integer is a number between 0 and 255 (decimal)


"hex" , where hex is a number between 0x0 and 0xFF (hexadecimal)

Description:

The unescape function is not a method associated with any object, but is part of the language itself. The string returned by unescape is a series of
characters in the ISO Latin-1 encoding.

See also:

escape function .

UTC Method

Returns the number of milliseconds in a date object, starting January 1, 1970 00:00:00, GMT.

Syntax:

Date.UTC ( year, month, day, [, hrs] [, min] [, sec] )

year year after 1990.


month month between 0-11.
day is the day of the month between 1-31.
hrs hours between 0-23.
min minutes between 0-59.
sec seconds between 0-59.

Method:

Date

Description:

file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 48/50


13/2/2020 JavaScript Methods and Functions

UTC takes the date parameters, separated by a comma, and returns the number of milliseconds since January 1, 1970 00:00:00, GMT.
Since UTC is a static Date method, use it as Date.UTC (), and not as a method of the date object you created.

See also:

parse method .

Write method

Writes one or more HTML expressions to a document in the specified window.

Syntax:

document.write ( expression1 [, expression2], ... [, expressionN] )

with expression1 on expressionN any JavaScript expression or a property of an existing object.

Method:

document

Description:

The write method displays any number of expressions in a document window. You can define any JavaScript expression with the write method,
including numeric, string, or boolean.
The write method is the same as the writeln method, but the write method does not add a newline character to the end of the output.
The write method is used inside the <SCRIPT> tag or inside an event. Events are executed after the document is closed, so the write method will open
a new document with mimeType text / html by default , unless you specify the document.open () method in the event.

See also:

methods close , open , writeln .

Writeln method

Writes one or more HTML expressions to a document in the specified window, adding a newline character to the end of the output.

Syntax:
file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 49/50
13/2/2020 JavaScript Methods and Functions

document.writeln ( expression1 [, expression2], ... [, expressionN] )

with expression1 on expressionN any JavaScript expression or a property of an existing object.

Method:

document

Description:

The writeln method displays any number of expressions in a document window. You can define any JavaScript expression with the write method,
including numeric, string, or boolean.
The writeln method is the same as the write method, but the writeln method adds a newline character to the end of the output. HTML ignores
newlines, with the exception of certain tags, such as <PRE>.
The writeln method is used inside any <SCRIPT> tag or inside an event. Events are executed after the document is closed, so the writeln method will
by default open a new document with mimeType text / html, unless you specify the document.open () method in the event.

See also:

methods close , open , write .

file:///C:/Users/Huynh Ngoc Hoi/Downloads/jsmethod.html#32 50/50

You might also like