queryCommandState
Methods Reference

queryCommandState

Description

Returns the current state of the command.

Syntax

Boolean = object.queryCommandState(command)

ParameterDescription
command (String) String that specifies the command to query. Can be any valid command identifier.

Return Value

Returns TRUE if the given command has been carried out on the object, FALSE if it has not, and NULL if it is not possible to determine the command state.

Applies To

document, TextRange

See Also

execCommand, queryCommandEnabled, queryCommandIndeterm, queryCommandSupported, queryCommandValue


queryCommandSupported

Description

Returns whether the current command is supported on the current range.

Syntax

Boolean = object.queryCommandSupported(command)

ParameterDescription
command (String) String that specifies the command to query. Can be any valid command identifier.

Return Value

Returns TRUE if the command is supported, or FALSE otherwise.

Applies To

document, TextRange

See Also

execCommand, queryCommandEnabled, queryCommandIndeterm, queryCommandState, queryCommandValue


queryCommandValue

Description

Returns the current value of the given command. If the command returns a value such as a color rather than a TRUE/FALSE state, this command is used to retrieve the current value of the document or range.

Syntax

string = object.queryCommandValue(command)

ParameterDescription
command (String) String that specifies the command to query. Can be any valid command identifier.

Return Value

Returns a string representing the command value if the command is supported, or TRUE/FALSE.

Applies To

document, TextRange

See Also

execCommand, queryCommandEnabled, queryCommandIndeterm, queryCommandState, queryCommandSupported


refresh

Description

Refreshes the content of the table.

Syntax

object.refresh( )

Return Value

No return value.

Applies To

TABLE


reload

Description

Reloads the current page.

Syntax

object.reload( )

Return Value

No return value.

Applies To

location


remove

Description

Removes an element from the collection.

Syntax

object.remove(index)

ParameterDescription
index Number or string specifying the element to remove. If this parameter is a number, the method removes the element at the given position in the collection, where 0 is the first position, 1 the second, and so on. If this parameter is a string, the method removes all elements having a name or id property equal to the string.

Return Value

No return value.

Remarks

For the areas object, this method can only be used on the object after the page has been loaded. If the method is applied "inline," a run-time error will occur.

Applies To

areas, options

See Also

add


removeAttribute

Description

Removes the given attribute from the element.

Syntax

Boolean = object.removeAttribute(attrName [, caseSensitive])

ParameterDescription
attrName String specifying the name of the attribute.
caseSensitive Optional. Boolean value specifying whether to use a case-sensitive search to locate the attribute. If TRUE, the uppercase and lowercase letters in attrName must match exactly those in the attribute name. By default, this parameter is TRUE. If there are multiple attributes specified with different case sensitivity, the attribute returned might vary across platforms.

Return Value

Returns TRUE if successful, or FALSE otherwise.

Remarks

If two or more attributes have the same name (differing only in uppercase and lowercase letters) and caseSensitive is FALSE, this method removes only the last attribute (the last to be created with this name). All other attributes of the same name are ignored.

Applies To

A, ADDRESS, APPLET, AREA, B, BASE, BASEFONT, BGSOUND, BIG, BLOCKQUOTE, BODY, BR, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, COMMENT, DD, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM, FRAME, FRAMESET, H1, H2, H3, H4, H5, H6, HEAD, HR, HTML, I, IFRAME, IMG, INPUT, KBD, LABEL, LEGEND, LI, LINK, LISTING, MAP, MARQUEE, MENU, META, NEXTID, OBJECT, OL, OPTION, P, PLAINTEXT, PRE, S, SAMP, SCRIPT, SELECT, SMALL, SPAN, STRIKE, STRONG, STYLE, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TITLE, TR, TT, U, UL, VAR, WBR, XMP, style


replace

Description

Replaces the current document by loading the document at the given url. This method also removes the current document from the browser's session history.

Syntax

object.replace(url)

ParameterDescription
url String specifying the URL to insert into the session history.

Remarks

Replacing a document causes it to no longer be accessible through the history object. Also, the URL is no longer accessible through the user interface navigation methods (Back, Forward, and so on).

Applies To

location


reset

Description

Simulates a mouse click on a reset button for the calling form.

Syntax

object.reset( )

Return Value

No return value.

Applies To

FORM

See Also

INPUT, button, submit


resizeBy

Description

Changes the size of the window outside dimensions by the specified x and y offset relative to its current size.

Syntax

object.resizeBy(x, y)

ParameterDescription
x (Long) Horizontal scroll offset, in pixels.
y (Long) Vertical scroll offset, in pixels.

Return Value

No return value.

Applies To

window


resizeTo

Description

Sets the size of the window outside dimensions to the specified x and y pixel sizes.

Syntax

object.resizeTo(x, y)

ParameterDescription
x (Long) Horizontal scroll offset, in pixels.
y (Long) Vertical scroll offset, in pixels.

Return Value

No return value.

Applies To

window


scroll

Description

Causes the window to scroll to the specified x and y offset at the upper-left corner of the window. The preferred method for this is scrollTo; the scroll method is provided for backward compatibility only.

Syntax

object.scroll(x, y)

ParameterDescription
x (Long) Horizontal position, in pixels.
y (Long) Vertical offset, in pixels.

Return Value

No return value.

Applies To

window


scrollBy

Description

Causes the window to scroll relative to the current scrolled position by the specified x and y pixel offsets.

Syntax

object.scrollBy(x, y)

ParameterDescription
x (Long) Horizontal scroll offset, in pixels.
y (Long) Vertical scroll offset, in pixels.

Return Value

No return value.

Remarks

Positive values of x/y scroll further right/down; negative values scroll further left/up. Setting the scroll position beyond the limits results in the extreme valid scroll position in the direction specified.

Applies To

window


scrollIntoView

Description

Causes the object to scroll into view, aligning it at either the top or bottom of the window.

Syntax

object.scrollIntoView([start])

ParameterDescription
start Optional. Boolean value specifying whether to place the object at the top of the window or at the bottom. If TRUE, the method causes the object to scrolls so that its top is visible at the top of the window. If FALSE, the bottom of the object is visible at the bottom of the window. If no value is given, the object scrolls to the top by default.

Return Value

No return value.

Remarks

The following example causes the element to scroll into view within the window, placing it at either the top or bottom of the window. The method is useful for immediately showing the user the result of some action without requiring the user to manually scroll through the document to find the result. This example underlines the content of the fifth paragraph and scrolls it into view at the top of the window.

var coll = document.all.tags("P");
if (coll.length>=5) {
    coll(4).style.textDecoration = "underline";
    coll(4).scrollIntoView(true);
}

Depending on the size of the given object and the current window, this method might not be able to put the item at the very top or very bottom, but will always position the object as close to the requested position as possible.

Applies To

A, ADDRESS, APPLET, AREA, B, BIG, BLOCKQUOTE, BR, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, COMMENT, DD, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM, H1, H2, H3, H4, H5, H6, HR, I, IFRAME, IMG, INPUT, KBD, LABEL, LEGEND, LI, LISTING, MAP, MARQUEE, MENU, OBJECT, OL, P, PLAINTEXT, PRE, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, WBR, XMP, TextRange


scrollTo

Description

Scrolls the window to the specified x and y offsets at the upper-left corner of the window.

Syntax

object.scrollTo(x, y)

ParameterDescription
x (Long) Horizontal scroll offset, in pixels.
y (Long) Vertical scroll offset, in pixels.

Return Value

No return value.

Applies To

window


select

Description

Highlights the input area of a form element.

Syntax

object.select( )

Return Value

No return value.

Remarks

You can use the select method with the focus method to highlight a field and position the cursor for a user response.

Applies To

INPUT, TEXTAREA

See Also

onselect


select

Description

Makes the active selection equal to the current object.

Syntax

object.select( )

Return Value

No return value.

Remarks

This feature might not be available on non-Win32 platforms. See article Q172976 in the Microsoft Knowledge Base for the latest information on Internet Explorer cross-platform compatibility.

Applies To

TextRange


setAttribute

Description

Sets the value of the given attribute. If the attribute is not already present, the method adds the attribute to the element and sets the value.

Syntax

object.setAttribute(attrName , value [, caseSensitive])

ParameterDescription
attrName String specifying the name of the attribute.
value String, number, or Boolean value to assign to the attribute.
caseSensitive Optional. Boolean value specifying whether to use a case-sensitive search to locate the attribute. If TRUE, the uppercase and lowercase letters in attrName must match exactly those in the attribute name. By default, this parameter is TRUE.

Return Value

No return value.

Remarks

Be careful when spelling attribute names. If caseSensitive is TRUE and attrName does not have the same uppercase and lowercase letters as the attribute, this method creates a new attribute.

If two or more attributes have the same name (differing only in uppercase and lowercase letters) and caseSensitive is FALSE, this method assigns a value only to the first attribute (the first to be created with this name). All other attributes of the same name are ignored.

Applies To

A, ADDRESS, APPLET, AREA, B, BASE, BASEFONT, BGSOUND, BIG, BLOCKQUOTE, BODY, BR, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, COMMENT, DD, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM, FRAME, FRAMESET, H1, H2, H3, H4, H5, H6, HEAD, HR, HTML, I, IFRAME, IMG, INPUT, KBD, LABEL, LEGEND, LI, LINK, LISTING, MAP, MARQUEE, MENU, META, NEXTID, OBJECT, OL, OPTION, P, PLAINTEXT, PRE, S, SAMP, SCRIPT, SELECT, SMALL, SPAN, STRIKE, STRONG, STYLE, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TITLE, TR, TT, U, UL, VAR, WBR, XMP, style


setEndPoint

Description

Sets the end point of one range based on the end point of another. This method takes two parameters: a string that describes the end points to transfer, and a range from which the source end point will be taken.

Syntax

object.setEndPoint(type, range)

ParameterDescription
type String that describes the end point to transfer. Can be one of these values:
StartToEnd
StartToStart
EndToStart
EndToEnd
range Text range object specifying the range from which the source end point is to be taken.

Return Value

No return value.

Remarks

This feature might not be available on non-Win32 platforms. See article Q172976 in the Microsoft Knowledge Base for the latest information on Internet Explorer cross-platform compatibility.

Example

The following JScript example sets the start point of the current range (r1) to the end point of the second range (r2).

r1.setEndPoint("StartToEnd", r2);

Applies To

TextRange


setInterval

Description

Repeatedly evaluates an expression after a specified number of milliseconds has elapsed.

Syntax

intervalID = object.setInterval(expression, msec [, language])

ParameterDescription
expression String containing the script code to execute each time the interval elapses.
msec Integer value or numeric string specifying the length of the interval, in milliseconds.
language Optional. String specifying the language in which the code is executed.

Return Value

Returns an integer identifier representing the interval. Use this identifier to clear (stop) the interval.

Example

The following example sets a 15-second interval. Each time the interval elapses, the background color of the document changes.

setInterval("changeColor()", 15000);
   .
   .
   .
function changeColor() {
    if (document.body.bgColor == "red")
        document.body.bgColor == "blue";
    else
        document.body.bgColor == "red";
}

Applies To

window

See Also

clearInterval


setTimeout

Description

Evaluates an expression after a specified number of milliseconds has elapsed.

Syntax

timeoutID = object.setTimeout(expression, msec [, language])

ParameterDescription
expression (String) Code to be executed at the specified interval.
msec (Long) Numeric value or numeric string in millisecond units.
language Optional. (String) String that specifies the language in which the code is executed.

Return Value

Returns an identifier that is used only to cancel the evaluation with the clearTimeout method.

Applies To

window

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.