insertCell
Methods Reference

insertCell

Description

Creates a new cell in the table row and adds the cell to the cells collection.

Syntax

object.insertCell(index)

Return Value

Returns the TD element object. If the method fails, it returns null. Index is optional. Default value is "-1" which appends the TD to the end of the cells collection.

Remarks

The following example adds a cell to the end of the TR,


myNewCell = document.all.myTable.rows[0].insertCell() 

Applies To

TR

See Also

deleteCell, InsertRow


insertRow

Description

Creates a new row (TR) in the table and adds the row to the rows collection. Inserting a row in a TFOOT, TBODY, or THEAD also adds a row to the rows collection for the TABLE. Inserting a row in the TABLE, adds a row to the rows collection for the TBODY. If specifying an index, the index should be relative to the rows collection for the element which first contains the TR. For example, insertRow for a TBODY would take an index value relative to the rows collection that is on the TBODY, not the TABLE.

Syntax

object.insertRow(index)

Return Value

Returns the TR element object. If the method fails, it returns null. Index is optional. Default value is "-1" which appends the TD to the end of the rows collection.

Remarks

The following example adds a row to the TABLE,


myNewRow = document.all.myTable.insertRow()

Applies To

table, TBODY, TFOOT, THEAD

See Also

rows, rowIndex, sectionRowIndex


isEqual

Description

Returns whether the specified range is equal to the current range.

Syntax

Boolean = object.isEqual(compareRange)

ParameterDescription
compareRange (TextRange) Range object.

Return Value

Returns TRUE if equal, FALSE otherwise.

Applies To

TextRange

See Also

inRange


isSubscribed

Description

Returns whether the given channel is subscribed to by the client.

Syntax

Boolean = object.isSubscribed(urlToCDF)

ParameterDescription
urlToCDF Required. Specifies the URL of a Channel Definition Format (CDF) file to be checked for a subscription.

Return Value

Returns true if the channel is subscribed to, or false if no subscription exists for that CDF file.

Remarks

For security purposes, if this method is used in an HTML page that is not in the same secondary domain specified in the urlToCDF, the method will return a scripting error.

Further information is available on Creating Active Channels.

Applies To

external


item

Description

Retrieves an element or a collection from the given collection. The index determines which action to take.

Syntax

element = object.item(index [, subindex])

ParameterDescription
index Number or string specifying the element or collection to retrieve. If this parameter is a number, the method returns the element in the collection at the given position, where the first element has value 0, the second has 1, and so on. If this parameter is a string, the method returns a collection of elements, where the value of the name or id property for each element is equal to the string.
subindex Optional. Number specifying the position of an element to retrieve. This parameter is used when index is a string. The method uses the string to construct a collection of all elements that have a name or id equal to the string, then retrieves from this collection the element at the position specified by subindex.

Return Value

Returns an element object or a collection of element objects if successful, or null otherwise.

Examples

The following JScript example uses the item method to retrieve each element from the document. In this case, the method parameter is a number, so the elements are retrieved in the order in which they appear in the document.

var coll = document.all;
if (coll!=null) {
    for (i=0; i<coll.length; i++) 
        alert(coll.item(i).tagName);
}

The following JScript example uses the item method to retrieve a collection of all elements in the document having "Sample" as an id. It then uses item again to retrieve each element from the "Sample" collection.

var coll = document.all.item("Sample");
If (coll != null) {
    for (i=0; i<coll.length; i++) {
        alert(coll.item(i).tagName);
    }
}

The following JScript example is similar to the previous example, but uses the optional subindex parameter of item to retrieve individual elements.

var coll = document.all.item("Sample")
if (coll!=null) {
    for (i=0; i<coll.length; i++)
        alert(document.all.item("Sample",i).tagName);
}

Applies To

all, anchors, applets, areas, cells, elements, embeds, filters, forms, frames, images, imports, links, options, plugins, rows, scripts, styleSheets


javaEnabled

Description

Returns whether Java is enabled.

Syntax

Boolean = object.javaEnabled( )

Return Value

Returns TRUE if Java is enabled, or FALSE otherwise.

Applies To

navigator


move

Description

Collapses the given text range and moves the empty range by the given number of units.

Syntax

long = object.move(unit [, count])

ParameterDescription
unit String specifying the units to move. Can be one of the following:
character Moves one or more characters.
word Moves one or more words. A word is a collection of characters terminated by a space or other white-space character.
sentence Moves one or more sentences. A sentence is a collection of words terminated by a punctuation character, such as a period.
textedit Moves to the start or end of the original range.
count Optional. Integer specifying the number of units to move. This can be positive or negative. When omitted, defaults to 1.

Return Value

Returns the actual number of units moved.

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

See Also

moveEnd, moveStart


moveBy

Description

Moves the screen position of the window by the specified x and y offsets relative to its current position.

Syntax

object.moveBy(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


moveEnd

Description

Changes the scope of the range by moving the end position of the range.

Syntax

long = object.moveEnd(unit [, count])

ParameterDescription
unit String specifying the units to move. Can be one of the following strings:
character Moves one or more characters.
word Moves one or more words. A word is a collection of characters terminated by a space or other white-space character.
sentence Moves one or more sentences. A sentence is a collection of words terminated by a punctuation character, such as a period.
textedit Moves to the start or end of the original range.
count Optional. Integer specifying the number of units to move. This can be positive or negative. When omitted, defaults to 1.

Return Value

Returns the actual number of units moved.

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

See Also

move, moveStart


moveStart

Description

Changes the scope of the range by moving the start position of the range.

Syntax

long = object.moveStart(unit [, count])

ParameterDescription
unit String specifying the units to move. Can be one of the following strings:
character Moves one or more characters.
word Moves one or more words. A word is a collection of characters terminated by a space or other white-space character.
sentence Moves one or more sentences. A sentence is a collection of words terminated by a punctuation character, such as a period.
textedit Moves to the start or end of the original range.
count Optional. Integer specifying the number of units to move. This can be positive or negative. When omitted, defaults to 1.

Return Value

Returns the actual number of units moved.

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

See Also

move, moveEnd


moveTo

Description

Moves the screen position of the upper-left corner of the window to the specified x and y pixel position.

Syntax

object.moveTo(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


moveToBookmark

Description

Moves to a bookmark. Bookmarks are opaque strings that are created with the getBookmark method.

Syntax

Boolean = object.moveToBookmark( )

Return Value

Returns TRUE if successful, or FALSE otherwise.

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


moveToElementText

Description

Moves the text range so that the start and end positions of the range encompass the text in the given element.

Syntax

object.moveToElementText(element)

ParameterDescription
element Element object.

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


moveToPoint

Description

Moves the start and end positions of the text range to the given point. The coordinates of the point must be in pixels and be relative to the upper-left corner of the window. The resulting text range is empty, but can be expanded and moved using methods such as expand and moveEnd.

Syntax

object.moveToPoint(x, y)

ParameterDescription
x Integer specifying the x-coordinate, in pixels.
y Integer specifying the y-coordinate, in pixels.

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 moves the text range to the same point as the user clicked the mouse, then expands the range and selects the text within the new range.

<SCRIPT FOR=document EVENT=onclick LANGUAGE="JScript">
var rng = document.body.createTextRange();
rng.moveToPoint(window.event.x, window.event.y);
rng.expand("word");
rng.select();
</SCRIPT>

Applies To

TextRange


navigate

Description

Equivalent to the window.location.href property.

Syntax

object.navigate(URL)

ParameterDescription
URL (String) URL to be displayed.

Return Value

No return value.

Applies To

window

See Also

href property


nextPage

Description

Allows viewing the next page of records in the data set to which the table is bound.

Syntax

object.nextPage( )

Return Value

No return value.

Remarks

The number of records displayed in the table is determined by the dataPageSize property of the table. The Web author must set the DATAPAGESIZE attribute when designing the page or set the corresponding dataPageSize property at run time for this method to have any effect.

Note The page author does not need to check for boundary conditions.

Applies To

table

See Also

previousPage


open

Description

Opens a new window and loads the document given by URL, or a blank document if a URL is not provided.

Syntax

window = object.open([URL [, name [, features [, replace]]]])

ParameterDescription
URL String specifying the URL of the document to display. If no URL is specified, a new window with about:blank will be displayed.
name Optional. String specifying the name of the window. This name is used for TARGET on a FORM or an A.
features Optional. String specifying the window ornaments to display. The following table lists the supported features.
Syntax Description
fullscreen={ yes | no | 1 | 0 } Specifies whether to display the browser in a full-screen or normal window. Default is no.

Use full-screen mode carefully. Because this mode hides the browser's title bar and menus, you should always provide a button or other visual clue to help the user close the window. ALT+F4 will also close the new window.

channelmode={ yes | no | 1 | 0 } Specifies whether to display the window in theater mode and show the channel band.
toolbar={ yes | no | 1 | 0 } Specifies whether to display the browser toolbar, making buttons such as Back, Forward, and Stop available.
location= { yes | no | 1 | 0 } Specifies whether to display the input field for entering URLs directly into the browser.
directories = { yes | no | 1 | 0 } Specifies whether to add directory buttons. Default is no.
status={ yes | no | 1 | 0 } Specifies whether to add a status bar at the bottom of the window. Default is yes.
menubar={ yes | no | 1 | 0} Specifies whether to display the menu bar. Default is yes.
scrollbars={ yes | no | 1 | 0} Specifies whether to display horizontal and vertical scroll bars. Default is yes.
resizable={ yes | no | 1 | 0} Specifies whether to display resize handles at the corners of the window.
width=number Sets the width of the window, in pixels. Minimum value should be 100.
height=number Specifies the height of the window, in pixels. Minimum value should be 100.
top=number Specifies the top position, in pixels. This value is relative to the upper-left corner of the screen.
left=number Specifies the left position, in pixels. This value is relative to the upper-left corner of the screen.
replace Optional. A boolean value specifying whether the URL that is loaded into the new page should create a new entry in the window's browsing history or replace the current entry in the browsing history. If true, no new history entry is created.

Return Value

Returns a reference to the new window. Use this reference to script properties and methods on the new window.

Remarks

A name for the new window can be used as a target for a form or an A element. By default, the open() method creates a window that has a default width and height and the standard menu, toolbar, and other features of Internet Explorer. You can alter this set of features by using the features parameter. This parameter is a string consisting of one or more feature settings. The replace parameter controls whether the new window is put into the browser history list.

For example, the following creates a new window that contains Sample.htm. The new window is 200 by 400 pixels, has a status bar, but does not have a toolbar, menu bar, or address field.

window.open("sample.htm",null,
    "height=200,width=400,status=yes,toolbar=no,menubar=no,location=no");

Applies To

window


open

Description

Opens a stream to collect the output of write or writeln methods.

Syntax

document.open(mimeType, replace)

ParameterDescription
mimeType Currently supports "text/html" only.
replace Optional. String ("replace") indicating whether you want the new document you are writing to replace the current document in the History list. Otherwise, by default, the document you are creating will not replace the current document in the History list.

Return Value

No return value.

Remarks

The following example replaces the document with the new document.

document.open("text/html", "replace")

Applies To

document

Events

onbeforeunload


parentElement

Description

Retrieves the parent element for the given text range. The parent element is the element that completely encloses the text in the range.

Syntax

element = object.parentElement( )

Return Value

Returns an element object if successful, or null otherwise.

Remarks

If the text range spans text in more than one element, this method returns the smallest element that encloses all the elements. When you insert text into a range that spans multiple elements, the text is placed within the parent element rather than in any of the contained elements.

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 retrieves the parent element for the text range created from the current selection and displays the tag name of the element.

var sel = document.selection;
var rng = sel.createRange();
var el = rng.parentElement();
alert(el.tagName);

Applies To

TextRange


pasteHTML

Description

Pastes HTML text into the given text range. The text completely replaces any previous text and HTML elements in the range.

Syntax

object.pasteHTML(htmlText)

ParameterDescription
htmlText String specifying the HTML text to paste. The string can contain text and any combination of the HTML tags described in HTML Elements.

Return Value

No return value.

Remarks

Although this method never fails, it might alter the HTML text to make it fit the given text range. For example, attempting to paste a table cell into a text range that does not contain a table might cause the method to insert a TABLE element. For predictable results, you should paste only well-formed HTML text that is appropriate for the given text range.

Note You cannot use this method while the document is loading. Wait until the document is completely downloaded.

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 replaces the current selection with a new paragraph.

var sel = document.selection;
if (sel!=null) {
    var rng = sel.createRange();
    if (rng!=null)
        rng.pasteHTML("<P><B>Selection has been replaced.</B>");
}

Applies To

TextRange


previousPage

Description

Allows viewing the previous page of records in the data set to which the table is bound.

Syntax

object.previousPage

Return Value

No return value.

Remarks

The number of records displayed in the table is determined by the dataPageSize property of the table. The Web author must set the DATAPAGESIZE attribute when designing the page or set the corresponding dataPageSize property at run time for this method to have any effect.

Note The page author does not need to check for boundary conditions.

Applies To

TABLE

See Also

nextPage


prompt

Description

Displays a Prompt dialog box with a message and an input field.

Syntax

object.prompt([message [, inputDefault]])

ParameterDescription
message Optional. (String) String to display.
inputDefault Optional. (String) String or integer that represents the default value of the input field.

Return Value

Returns the value that the user types in.

Remarks

If the inputDefault parameter is not supplied, the dialog box displays the value <undefined>. You have no control over the title of the prompt box.

Applies To

window


queryCommandEnabled

Description

Returns whether the command can be successfully executed using ExecCommand now, given the current state of the document.

Syntax

Boolean = object.queryCommandEnabled(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 enabled, or FALSE otherwise.

Remarks

Note: queryCommandEnabled("delete") on TextRange returns TRUE, while queryCommandEanbled("delete") on Document returns FALSE, but you can still use execCommand("Delete") to delete the selected text.

Applies To

document, TextRange

See Also

execCommand, queryCommandIndeterm, queryCommandState, queryCommandSupported, queryCommandValue


queryCommandIndeterm

Description

Returns whether the specified command is in the indeterminate state.

Syntax

Boolean = object.queryCommandIndeterm(command)

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

Return Value

Returns TRUE if indeterminate, or FALSE otherwise.

Remarks

As an example, given a text range, if some of the characters are bold and others are not, queryCommandIndeterm for bold would return TRUE.

Applies To

document, TextRange

See Also

execCommand, queryCommandEnabled, queryCommandState, queryCommandSupported, queryCommandValue

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