Both the proprietary Internet Explorer DOM and W3C DOM expose a wide range of properties (including event handler properties) and methods almost universally across objects that reflect HTML elements. Rather than repeat the descriptions of these items ad nauseam in the reference listing, I am listing their details only once. Due to the large number of shared items (80 properties, 60 methods, and 72 event types), these shared items do not appear in the lists of properties, methods, and events for each object in the rest of this chapter, but they are available for practically every HTML element object (within the browser or standard version range indicated in each listing).
Obviously, the shared properties or methods that are meaningless except for rendered element objects may not be available to nonrendered elements. For example, invoking the IE scrollIntoView( ) method of a style element object is meaningless because the style element presents no content of its own on the page to which a window could scroll. Such items are typically part of the DOMs simply because the browsers' internal architectures utilize an inheritance mechanism that empowers all element objects with the same basic items, even if they have no particular application. You should get to know the shared items well, and refer to the object-specific items later in this chapter when you need their special powers.
In the following item descriptions, the example code uses the term elementID to refer to the identifier assigned to the id attribute of the element. In your scripts, substitute the object's true ID for the placeholder used here. Here is a list of the common items:
|
ATTRIBUTE_NODE |
CDATA_SECTION_NODE |
COMMENT_NODE |
|
DOCUMENT_FRAGMENT_NODE |
DOCUMENT_NODE |
DOCUMENT_TYPE_NODE |
|
ELEMENT_NODE |
ENTITY_NODE |
ENTITY_REFERENCE_NODE |
|
NOTATION_NODE |
PROCESSING_INSTRUCTION_NODE |
TEXT_NODE |
|
accessKey |
all[] |
attributes[] |
|
baseURI |
behaviorUrns[] |
canHaveChildren |
|
canHaveHTML |
childNodes[] |
children |
|
cite |
className |
clientHeight |
|
clientLeft |
clientTop |
clientWidth |
|
contentEditable |
currentStyle |
dateTime |
|
dir |
disabled |
document |
|
filters[] |
firstChild |
hideFocus |
|
id |
innerHTML |
innerText |
|
isContentEditable |
isDisabled |
isMultiLine |
|
isTextEdit |
lang |
language |
|
lastChild |
localName |
namespaceURI |
|
nextSibling |
nodeName |
nodeType |
|
nodeValue |
offsetHeight |
offsetLeft |
|
offsetParent |
offsetTop |
offsetWidth |
|
outerHTML |
outerText |
ownerDocument |
|
parentElement |
parentNode |
parentTextEdit |
|
prefix |
previousSibling |
readyState |
|
recordNumber |
runtimeStyle |
scopeName |
|
scrollHeight |
scrollLeft |
scrollTop |
|
scrollWidth |
sourceIndex |
style |
|
tabIndex |
tagName |
tagUrn |
|
title |
uniqueID |
|
addBehavior( ) |
addEventListener( ) |
appendChild( ) |
|
applyElement( ) |
attachEvent( ) |
blur( ) |
|
clearAttributes( ) |
click( ) |
cloneNode( ) |
|
componentFromPoint( ) |
contains( ) |
createControlRange( ) |
|
detachEvent( ) |
dispatchEvent( ) |
doScroll( ) |
|
dragDrop( ) |
fireEvent( ) |
focus( ) |
|
getAdjacentText( ) |
getAttribute( ) |
getAttributeNode( ) |
|
getAttributeNodeNS( ) |
getAttributeNS( ) |
getBoundingClientRect( ) |
|
getClientRects( ) |
getElementsByTagName( ) |
getElementsByTagNameNS( ) |
|
getExpression( ) |
hasAttribute( ) |
hasAttributeNS( ) |
|
hasAttributes( ) |
hasChildNodes( ) |
insertAdjacentElement( ) |
|
insertAdjacentHTML( ) |
insertAdjacentText( ) |
insertBefore( ) |
|
isSupported( ) |
mergeAttributes( ) |
normalize( ) |
|
releaseCapture( ) |
removeAttribute( ) |
removeAttributeNode( ) |
|
removeAttributeNS( ) |
removeBehavior( ) |
removeChild( ) |
|
removeEventListener( ) |
removeExpression( ) |
removeNode( ) |
|
replaceAdjacentText( ) |
replaceChild( ) |
replaceNode( ) |
|
scrollIntoView( ) |
setActive( ) |
setAttribute( ) |
|
setAttributeNode( ) |
setAttributeNodeNS( ) |
setAttributeNS( ) |
|
setCapture( ) |
setExpression( ) |
swapNode( ) |
|
Events |
IE Windows |
IE Mac |
NN |
W3C DOM |
|---|---|---|---|---|
|
DOMActivate[13] |
n/a |
n/a |
n/a |
2 |
|
DOMAttrModified[13] |
n/a |
n/a |
6 |
2 |
|
DOMCharacterDataModified[13] |
n/a |
n/a |
6 |
2 |
|
DOMFocusIn[13] |
n/a |
n/a |
n/a |
2 |
|
DOMFocusOut[13] |
n/a |
n/a |
n/a |
2 |
|
DOMNodeInserted[13] |
n/a |
n/a |
6 |
2 |
|
DOMNodeInsertedIntoDocument[13] |
n/a |
n/a |
6 |
2 |
|
DOMNodeRemoved[13] |
n/a |
n/a |
6 |
2 |
|
DOMNodeRemovedFromDocument[13] |
n/a |
n/a |
6 |
2 |
|
DOMSubtreeModified[13] |
n/a |
n/a |
6 |
2 |
|
onactivate |
5.5 |
n/a |
n/a |
n/a |
|
onafterupdate[14] |
4 |
5 |
n/a |
n/a |
|
onbeforeactivate |
6 |
n/a |
n/a |
n/a |
|
onbeforecopy |
5 |
n/a |
n/a |
n/a |
|
onbeforecut |
5 |
n/a |
n/a |
n/a |
|
onbeforedeactivate |
5.5 |
n/a |
n/a |
n/a |
|
onbeforeeditfocus |
5 |
n/a |
n/a |
n/a |
|
onbeforepaste |
5 |
n/a |
n/a |
n/a |
|
onbeforeupdate[14] |
4 |
5 |
n/a |
n/a |
|
onblur[15] |
3 |
3.01 |
2 |
1 |
|
oncellchange[16] |
5 |
n/a |
n/a |
n/a |
|
onclick[15] |
3 |
3.01 |
2 |
1 |
|
oncontextmenu |
5 |
n/a |
n/a |
n/a |
|
oncontrolselect |
5.5 |
n/a |
n/a |
n/a |
|
oncopy |
5 |
n/a |
n/a |
n/a |
|
oncut |
5 |
n/a |
n/a |
n/a |
|
ondataavailable[16] |
4 |
n/a |
n/a |
n/a |
|
ondatasetchanged[16] |
4 |
n/a |
n/a |
n/a |
|
ondatasetcomplete[16] |
4 |
n/a |
n/a |
n/a |
|
ondblclick[15] |
4 |
4 |
3 |
n/a |
|
ondeactivate |
5.5 |
n/a |
n/a |
n/a |
|
ondrag |
5 |
n/a |
n/a |
n/a |
|
ondragend |
5 |
n/a |
n/a |
n/a |
|
ondragenter |
5 |
n/a |
n/a |
n/a |
|
ondragleave |
5 |
n/a |
n/a |
n/a |
|
ondragover |
5 |
n/a |
n/a |
n/a |
|
ondragstart |
5 |
n/a |
n/a |
n/a |
|
ondrop |
5 |
n/a |
n/a |
n/a |
|
onerrorupdate[14] |
4 |
5 |
n/a |
n/a |
|
onfilterchange |
4 |
n/a |
n/a |
n/a |
|
onfocus[15] |
3 |
3.01 |
2 |
1 |
|
onfocusin |
6 |
n/a |
n/a |
n/a |
|
onfocusout |
6 |
n/a |
n/a |
n/a |
|
onhelp[15] |
4 |
5 |
n/a |
n/a |
|
onkeydown[15] |
4 |
4 |
4 |
3 |
|
onkeypress[15] |
4 |
4 |
4 |
3 |
|
onkeyup[15] |
4 |
4 |
4 |
3 |
|
onlayoutcomplete |
5.5 |
n/a |
n/a |
n/a |
|
onlosecapture |
5 |
n/a |
n/a |
n/a |
|
onmousedown[15] |
4 |
4 |
4 |
1 |
|
onmouseenter |
5.5 |
n/a |
n/a |
n/a |
|
onmouseleave |
5.5 |
n/a |
n/a |
n/a |
|
onmousemove[15] |
4 |
4 |
4 |
1 |
|
onmouseout[15] |
3 |
3.01 |
2 |
1 |
|
onmouseover[15] |
3 |
3.01 |
2 |
1 |
|
onmouseup[15] |
4 |
4 |
4 |
1 |
|
onmousewheel |
6 |
n/a |
n/a |
n/a |
|
onmove |
5.5 |
n/a |
n/a |
n/a |
|
onmoveend |
5.5 |
n/a |
n/a |
n/a |
|
onmovestart |
5.5 |
n/a |
n/a |
n/a |
|
onpaste |
5 |
n/a |
n/a |
n/a |
|
onpropertychange |
5 |
n/a |
n/a |
n/a |
|
onreadystatechange[17] |
4 |
n/a |
n/a |
n/a |
|
onresize[15] |
4 |
4 |
4 |
n/a |
|
onresizeend |
5.5 |
n/a |
n/a |
n/a |
|
onresizestart |
5.5 |
n/a |
n/a |
n/a |
|
onrowenter[16] |
4 |
n/a |
n/a |
n/a |
|
onrowexit[16] |
4 |
n/a |
n/a |
n/a |
|
onrowsdelete[16] |
5 |
n/a |
n/a |
n/a |
|
onrowsinserted[16] |
5 |
n/a |
n/a |
n/a |
|
onscroll[18] |
4 |
4 |
n/a |
n/a |
|
onselectstart |
4 |
4 |
n/a |
n/a |
[13] Event type assignable only via the addEventListener( ) method for any node.
[14]Exposed as property for all elements in IE 6, but applies only to elements that support data binding: a, bdo, button, custom, div, frame, iframe, img, input (checkbox, hidden, password, radio, text), label, legend, marquee, rt, ruby, select, span, and textarea.
[15]Shared among all element objects only in recent browsers. Earlier implementations and compatibilities are listed with applicable objects throughout this chapter.
[16]Exposed as property for all elements in IE 6, but applies only to applet, object, and xml elements set for data binding.
[17]Exposed as property for all elements in IE 6, but applies only to applet, document, frame, frameSet, iframe, img, link, object, script, and xml elements unless an HTML behavior is attached to the element.
[18]Exposed as property for all elements in IE 6, but applies only applet, bdo, body, custom, div, embed, map, marquee, object, table, and textarea elements and the window object.
| ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE | NN 6 IE n/a DOM 1 |
| Read-only |
if (myObject.nodeType == document.ELEMENT_NODE) {
// process as an element here
}
Integer corresponding to DOM node type as follows.
| Property | nodeTypeValue |
|---|---|
|
ELEMENT_NODE |
1 |
|
ATTRIBUTE_NODE |
2 |
|
TEXT_NODE |
3 |
|
CDATA_SECTION_NODE |
4 |
|
ENTITY_REFERENCE_NODE |
5 |
|
ENTITY_NODE |
6 |
|
PROCESSING_INSTRUCTION_NODE |
7 |
|
COMMENT_NODE |
8 |
|
DOCUMENT_NODE |
9 |
|
DOCUMENT_TYPE_NODE |
10 |
|
DOCUMENT_FRAGMENT_NODE |
11 |
|
NOTATION_NODE |
12 |
Constant values (above).
| accessKey | NN n/a IE 4 DOM 1 |
| Read/Write |
Although listed here as a widely shared property, that isn't strictly the case across all implementations. Netscape 6 (per the W3C DOM) recognizes this property only for the following elements: a, area, button, input, label, legend, and textarea. To this list, IE 4 adds applet, body, div, embed, isindex, marquee, object, select, span, table, and td (but removes label and legend). IE 5 adds every other renderable element, but with a caution. Except for input and other form-related elements, you must also assign a tabindex attribute or tabIndex property value to the IE 5 and later element (even if it's simply a value of zero for all) to let the accelerator key combination bring focus to the element. As of Version 7, Netscape does not alter UI behavior if a script changes the property's value.
document.links[3].accessKey = "n";
Single alphanumeric (and punctuation) keyboard character.
Empty string.
| all[ ] | NN n/a IE 4 DOM n/a |
| Read-only |
As with all collections in Internet Explorer, you may use the traditional JavaScript array syntax (with square brackets around the index value) or IE's JScript alternative (with parentheses around the index value). If you are aiming for cross-browser deployment for collections that are available on both platforms, use the square brackets.
Unless you develop strictly for IE browsers, consider migrating to W3C DOM references via document.getElementById( ), implemented in IE 5 and later and Netscape 6.
object.all(index).objectPropertyOrMethod
object.all[index].objectPropertyOrMethod
object.all("elementID").objectPropertyOrMethod
object.all["elementID"].objectPropertyOrMethod
object.all.elementID.objectPropertyOrMethod
var inpVal = document.all.first_name.value;
Array (collection) of element object references in HTML source code order.
Current document's model.
| attributes[ ] | NN 6 IE 5 DOM 1 |
| Read-only |
For Netscape 6, the attributes array contains entries only for those attributes explicitly defined in the HTML source code for the element, including custom attributes. Scripted changes to attributes (additions or deletions) or their values are reflected in the attribute objects referenced by the attributes array.
In lieu of the named node map object methods, you may access individual attribute objects via standard JavaScript array syntax. By and large, however, it is far more convenient to access HTML element attribute values for scripting purposes either via their reflection as element object properties or via the element's getAttribute( ) and setAttribute( ) methods. For W3C DOM details (which are useful for XML document parsing), see the Attr and NamedNodeMap objects for properties and methods of these objects.
var ldAttr = document.getElementById("myImg").attributes.getNamedItem("longdesc");
Array (collection) of attribute object references in source code (Netscape 6), alphabetical-by-name (IE/Mac), or haphazard (IE/Windows) order.
Current element's model.
| baseURI | NN 6 IE n/a DOM 3 |
| Read-only |
var nodeSrc = myXMLDoc.firstChild.childNodes[14].baseURI;
Full URI string.
Current node's internal value.
| behaviorUrns[ ] | NN n/a IE 5(Win) DOM n/a |
| Read-only |
var htcCount = document.getElementById(elementID).behaviorUrns.length;
Array of (empty) strings.
Array of length 0.
| canHaveChildren | NN n/a IE 5(Win) DOM n/a |
| Read-only |
if (elementRef.canHaveChildren) {
// statements to insert or append child elements
}
Boolean value: true | false.
Element-specific.
| canHaveHTML | NN n/a IE 5.5(Win) DOM n/a |
| Read-only and Read/Write |
if (elementRef.canHaveHTML) {
// statements to insert content with HTML markup
}
Boolean value: true | false.
Element-specific.
| childNodes[ ] | NN 6 IE 5 DOM 1 |
| Read-only |
for (var i = 0; i < nodeRef.childNodes.length; i++) {
if (nodeRef.childNodes[i].nodeType == document.ELEMENT_NODE) {
// operate on an element
}
}
Array of node object references.
Array of length zero.
| children[ ] | NN n/a IE 4 DOM n/a |
| Read-only |
for (var i = 0; i < elementRef.children.length; i++) {
if (elementRef.children[i].tagName == "FORM") {
// operate on a form element
}
}
Array of element object references.
Array of length zero.
| cite | NN 6 IE 6 DOM 1 |
| Read/Write |
Any valid URL to a document on the World Wide Web, including absolute or relative URLs.
Empty string.
| className | NN 6 IE 4 DOM 1 |
| Read/Write |
document.getElementById("elementID").className = "altHighlighted";
Case-sensitive string. Multiple class names are space-delimited within the string.
Empty string.
| clientHeight, clientWidth | NN 7 IE 4 DOM n/a |
| Read-only |
var midHeight = document.body.clientHeight/2;
Integer pixel value.
0
| clientLeft, clientTop | NN n/a IE 4 DOM n/a |
| Read-only |
Integer pixel value.
0
| contentEditable | NN n/a IE 5.5(Win) DOM n/a |
| Read/Write |
document.getElementById("elementID").contentEditable = "true";
String constant: false | inherit | true.
inherit
| currentStyle | NN n/a IE 5 DOM n/a |
| Read-only |
var currSize = document.getElementById("elementID").currentStyle.fontSize;
style object reference.
The effective style object.
| dateTime | NN 6 IE 6 DOM 1 |
| Read/Write |
Date string.
Empty string.
| dir | NN 6 IE 5 DOM 1 |
| Read/Write |
ltr | rtl (case insensitive string).
ltr
| disabled | NN 6 IE 4 DOM 1 |
| Read/Write |
document.getElementById("myButton").disabled = true;
Boolean value: true | false.
false
| document | NN n/a IE 4 DOM n/a |
| Read-only |
var currDoc = document.getElementById("elementID").document;
document object reference.
The current document object.
| filters[ ] | NN n/a IE 4 DOM n/a |
Array of filter object references.
Array of length zero.
| firstChild, lastChild | NN 6 IE 5 DOM 1 |
| Read-only |
if (document.getElementById("elementID").firstChild.nodeType == 3) {
// process as a text node
}
Node object (including text node, HTML element node, etc.) reference.
null
| hideFocus | NN n/a IE 5.5(Win) DOM n/a |
| Read/Write |
document.getElementById("elementID").hideFocus = true;
Boolean value: true | false.
false
| id | NN 6 IE 4 DOM 1 |
| Read/Write |
var headID = document.getElementsByTagName("head")[0].id;
String.
Empty string.
| innerHTML | NN 6 IE 4 DOM n/a |
| Read/Write |
Netscape 6 supports this property as a convenience, even though the W3C DOM does not. Assigning a string lacking HTML tags to the innerHTML property has the same effect as assigning the string to the IE-only innerText property. In IE, you can read or write the source code that includes the element's tags via the outerHTML property.
document.getElementById("elementID").innerHTML = "How <i>now</i> brown cow?";
String that may or may not include HTML tags.
Empty string.
| innerText | NN n/a IE 4 DOM n/a |
| Read/Write |
document.getElementById("elementID").innerText = "How now brown cow?";
String.
Empty string.
| isContentEditable | NN n/a IE 5.5(Win) DOM n/a |
| Read-only |
if (document.getElementById("elementID").isContentEditable) {
// process the editable element
}
Boolean value: true | false.
false
| isDisabled | NN n/a IE 5.5(Win) DOM n/a |
| Read-only |
if (document.getElementById("elementID").isDisabled) {
// process the disabled element
}
Boolean value: true | false.
false
| isMultiLine | NN n/a IE 5.5(Win) DOM n/a |
| Read-only |
if (document.getElementById("elementID").isMultiLine) {
// process the element as a potential multiple-line element
}
Boolean value: true | false.
Element default.
| isTextEdit | NN n/a IE 4 DOM n/a |
| Read-only |
if (document.getElementById("elementID").isTextEdit) {
var rng = document.getElementById("elementID").createTextRange( );
}
Boolean value: true | false.
Element default.
| lang | NN 6 IE 4 DOM 1 |
| Read/Write |
document.getElementById("elementID").lang = "de";
Case-insensitive language code.
Browser default.
| language | NN n/a IE 4 DOM n/a |
| Read/Write |
document.getElementById("elementID").language = "vbscript";
Case-insensitive scripting language name as string: javascript | jscript | vbs | vbscript.
jscript
| lastChild |
| localName, namespaceURI, prefix | NN 6 IE n/a DOM 2 |
| Read-only |
<?xml version="1.0" encoding="ISO-8859-1"?> <results xmlns:libBook="http://catalog.umv.edu/schema"> <libBook:title libBook:rareBooks="true">De Principia</libBook:title> </results>
The properties reveal details about the element's naming characteristics. A localName is the equivalent of the nodeName property of the element, that is, the tag name within the scope of the entire document, even if the tag name is reused by another element originating from another namespace. The prefix, however, links the element with a prefix name that is normally defined with an xmlns attribute of a container in the XML document. This helps your script identify the namespace to which the element is associated. A further binding is revealed through the namespaceURI property, which returns the URI string assigned to the xmlns attribute of a container element. Although all three properties belong to the Node object, their values are null (or, rather, should be null, but in Netscape 6 are empty strings) for node types other than element and attribute nodes.
var allTitles = document.getElementsByTagName("title");
for (var i = 0; i < allTitles.length; i++) {
if (allTitles[i].prefix == "libBook" &&
allTitles[i].namespaceURI.indexOf("catalog.umv.edu") != -1) {
// process title elements from the desired namespace here
}
}
Strings.
For localName, the element's tag name. For others, an empty string.
| namespaceURI |
| nextSibling, previousSibling | NN 6 IE 5 DOM 1 |
| Read-only |
var nextNode = document.getElementById("elementID").nextSibling;
Node object (including text node, HTML element node, etc.) reference.
null
| nodeName | NN 6 IE 5 DOM 1 |
| Read-only |
if (document.getElementById("elementID").nextSibling.nodeName == "#text") {
// process as a text node
}
Fixed string for #cdata-section, #document, #document-fragment, and #text nodes; variable string for attribute, element, and other node types.
Node-specific.
| nodeType | NN 6 IE 5 DOM 1 |
| Read-only |
if (document.getElementById("elementID").firstChild.nodeType == 1) {
// process as an element
}
Integer values according to the following table.
|
Value |
Node type |
W3C DOM |
IE/Windows |
IE/Mac |
NN |
|---|---|---|---|---|---|
|
1 |
ELEMENT_NODE |
1 |
5 |
5 |
6 |
|
2 |
ATTRIBUTE_NODE |
1 |
6 |
5 |
6 |
|
3 |
TEXT_NODE |
1 |
5 |
5 |
6 |
|
4 |
CDATA_SECTION_NODE |
1 |
n/a |
n/a |
n/a |
|
5 |
ENTITY_REFERENCE_NODE |
1 |
n/a |
n/a |
na/ |
|
6 |
ENTITY_NODE |
1 |
n/a |
n/a |
n/a |
|
7 |
PROCESSING_INSTRUCTION_NODE |
1 |
n/a |
n/a |
n/a |
|
8 |
COMMENT_NODE |
1 |
6 |
5 |
6 |
|
9 |
DOCUMENT_NODE |
1 |
5 |
5 |
6 |
|
10 |
DOCUMENT_TYPE_NODE |
1 |
n/a |
n/a |
6 |
|
11 |
DOCUMENT_FRAGMENT_NODE |
1 |
n/a |
n/a |
6 |
|
12 |
NOTATION_NODE |
1 |
n/a |
n/a |
n/a |
Node-specific.
| nodeValue | NN 6 IE 5 DOM 1 |
| Read/Write |
document.getElementById("elementID").firstChild.nodeValue = "New Text!";
String, although IE for Windows may return an attribute node's value as a Number data type if the value consists of a numeric value. You should always assign a string to this property.
Empty string.
| offsetHeight, offsetWidth | NN 6 IE 4 DOM n/a |
| Read-only |
var midpoint = document.getElementById("elementID").offsetWidth/2;
Integer pixel count.
Element-specific.
| offsetLeft, offsetTop | NN 6 IE 4 DOM n/a |
| Read-only |
if (document.getElementById("elementID").offsetLeft <= 20 &&
document.getElementById("elementID").offsetTop <=40) {
...
}
Integer pixel count.
Element-specific.
| offsetParent | NN 6 IE 4 DOM n/a |
| Read-only |
var containerLeft = document.getElementById("elementID")offsetParent.offsetLeft;
Object reference.
body object.
| outerHTML | NN n/a IE 4 DOM n/a |
| Read/Write |
document.getElementById("elementID").outerHTML =
"<acronym id="quotes">NI<i>M</i>BY</acronym>";
String that may or may not include HTML tags.
Empty string.
| outerText | NN n/a IE 4 DOM n/a |
| Read/Write |
document.getElementById("elementID").outerText = "UNESCO";
String.
Empty string.
| ownerDocument | NN 6 IE 5(Mac)/6(Win) DOM 1 |
| Read-only |
var currDoc = document.getElementById("elementID").ownerDocument;
document object reference.
The current document object.
| parentElement | NN n/a IE 4 DOM n/a |
| Read-only |
You can jump multiple parent levels by cascading parentElement properties, as in:
document.getElementById("elementID").parentElement.parentElement;You can then use references to access a parent element's properties or methods.
The corresponding property for the W3C DOM is parentNode.
document.getElementById("elementID").parentElement.style.fontSize = "14pt";
Element object reference.
Element-specific.
| parentNode | NN 6 IE 5 DOM 1 |
| Read-only |
if (document.getElementById("elementID").parentNode.nodeType == 1) {
document.getElementById("elementID").parentNode.style.fontSize = "14pt";
}
Element object reference.
Node-specific.
| parentTextEdit | NN n/a IE 4 DOM n/a |
| Read-only |
var rangeElement = document.getElementById("elementID").parentTextEdit;
var rng = rangeElement.createTextRange( );
Element object reference.
body object.
| prefix |
| previousSibling |
| readyState | NN n/a IE 4 DOM n/a |
| Read-only |
When introduced with IE 4, the property was available for only the document, embed, img, link, object, script, and style objects. IE 5 expanded coverage to all HTML element objects.
if (document.readyState == "loading") {
//statements for alternate handling while loading
}
For all but the object element, one of the following values (as strings): uninitialized | loading | loaded | interactive | complete. Some elements may allow the user to interact with partial content, in which case the property may return interactive until all loading has completed. Not all element types return all values in sequence during the loading process. The object element returns numeric values for these five states. They range from 0 (uninitialized) to 4 (complete).
None.
| recordNumber | NN n/a IE 4 DOM n/a |
| Read-only |
<script for="tableTemplate" event="onclick">
myDataCollection.recordset.absoluteposition = this.recordNumber;
...
</script>
Integer.
null
| runtimeStyle | NN n/a IE 5 DOM n/a |
| Read/Write |
You can use the runtimeStyle object to assign multiple style properties by reassigning a CSS syntax rule to the runtimeStyle.cssText property. Assign an empty string to the cssText property to remove all in-line attribute values, allowing the regular style sheet cascade to control the element's effective style.
document.getElementById("elementID").runtimeStyle.cssText =
"border: 5px blue solid";
style object reference.
The effective style object and its explicitly defined style attribute values.
| scopeName, tagUrn | NN n/a IE 5(Win) DOM n/a |
| Read-only |
var allTitles = document.getElementsByTagName("title");
for (var i = 0; i < allTitles.length; i++) {
if (allTitles[i].scopeName == "libBook" &&
allTitles[i].tagUrn.indexOf("catalog.umv.edu") != -1) {
// process title elements from the desired namespace here
}
}
Strings.
HTML for scopeName; empty string for tagUrn.
| scrollHeight, scrollWidth | NN 7 IE 4 DOM n/a |
| Read-only |
Starting in IE 5 for Windows, all HTML elements have these properties, and the values for nonscrolling elements are the same as the offsetHeight and offsetWidth properties. Netscape 7 implements these properties for all elements, returning the height and width of the element, whether or not it's in view. The important point is that for key elements, such as the body, the properties mean different things and can disrupt cross-platform operation.
var midPoint = document.body.scrollHeight/2;
Positive integer or zero.
None.
| scrollLeft, scrollTop | NN 7 IE 4 DOM n/a |
| Read/Write |
document.body.scrollTop = 40;
Positive integer or zero.
0
| sourceIndex | NN n/a IE 4 DOM n/a |
| Read-only |
var whichElement = document.getElementById("elementID").sourceIndex;
Positive integer or zero.
Element-specific.
| style | NN 6 IE 4 DOM 2 |
| Read/Write |
document.getElementById("elementID").style.fontSize = "14pt";
style object.
None.
| tabIndex | NN 6 IE 4 DOM 1 |
| Read/Write |
The W3C DOM and Netscape 6 limit the tabIndex property to the following element objects: a, area, button, input, object, select, textarea. To this list, IE 4 adds applet, body, div, embed, isindex, marquee, span, table, and td. IE 5 adds every other renderable element. A negative value in IE (only) removes an element from tabbing order entirely.
Links and anchors cannot be tabbed to with the Mac version of IE 4, so the tabIndex property for a element objects is ignored in that version.
document.getElementById("link3").tabIndex = 6;
Integer.
0
| tagName | NN 6 IE 4 DOM 1 |
| Read-only |
var theTag = document.getElementById("elementID").tagName;
String.
Element-specific.
| tagUrn |
| title | NN 6 IE 4 DOM 1 |
| Read/Write |