objectNN 6 IE 4 DOM 1  

  

The object object reflects the object element. This is an updated way of embedding other media and external data into a document (through a plugin or, in IE for Windows, an ActiveX control). The depth and quality of implementation of this object (vis--vis the W3C specifications) is uneven across browser brands and versions. The most consistent implementation is in IE for Windows for loading ActiveX controls.

 
HTML Equivalent
 
<object>
 
Object Model Reference
 
[window.]document.getElementById("elementID")
 
Object-Specific Properties
 
alignaltaltHtmlarchiveBaseHref
borderclassidcodecodeBasecodeType
contentDocumentdatadataFlddataSrcdeclare
formheighthspacenameobject
standbytypeuseMapvspacewidth
 
Object-Specific Methods

None.

 
Object-Specific Event Handler Properties
 
HandlerNNIEDOM
onabortn/an/a2
onerrorn/a42
onloadn/an/a2
accessKeyNN n/a IE 4 DOM 1  

Read/Write  

This is single character key that either gives focus to an element (in some browsers) or activates a form control or link action. The browser and operating system determine if the user must press a modifier key (e.g., Ctrl, Alt, or Command) with the access key to activate the link. In Windows versions of IE 5 and later and Netscape 6, the Alt key is required and the key is not case-sensitive. For Macintosh versions of IE 5 and later and Netscape 6, the Ctrl modifier key is required to effect the action.

 

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.

 
Example
 
document.links[3].accessKey = "n";
 
Value

Single alphanumeric (and punctuation) keyboard character.

 
Default

Empty string.

alignNN n/a IE 4 DOM 1  

Read/Write  

Defines how the element is aligned relative to surrounding text content. Most values set the vertical relationship between the element and surrounding text. For example, to align the bottom of the element with the baseline of the surrounding text, the align property value would be baseline. An element can be "floated" along the left or right margin to let surrounding text wrap around the element.

 
Example
 
document.getElementById("myObject").align = "absmiddle";
 
Value

Any of the following alignment constant values (as a string): absbottom | absmiddle | baseline | bottom | right | left | none | texttop | top.

 
Default

bottom

altNN n/a IE 6(Win) DOM n/a  

Read/Write  

Indicates the text to be displayed (or spoken) where the object element appears on the page when a browser doesn't download graphics (or is waiting for the image to download). Presumably, Microsoft implemented this nonstandard property for occasions when the object element is used for the display of images, rather than the more common img element.

 
Example
 
document.getElementById("logoDisplay").alt = "MegaCorp Logo";
 
Value

String value.

 
Default

None.

altHtmlNN n/a IE 4 DOM n/a  

Read/Write  

Provides HTML content to be displayed if the object or applet fails to load. This can be a message, static image, or any other HTML that best fits the scenario. There are inconsistencies in Internet Explorer with regard to this property name's case. The Win32 version requires altHtml; the Mac version requires altHTML.

 
Example
 
document.getElementById("myObject").altHtml = "<img src='objectAlt.gif'>";
 
Value

Any quoted string of characters, including HTML tags.

 
Default

None.

archiveNN 6 IE 6(Win) DOM 1  

Read/Write  

Reflects the archive attribute of the object element, but Version 6 browsers assign no functionality to either the attribute or property.

 
Value

String value.

 
Default

None.

BaseHrefNN n/a IE 4(Win) DOM n/a  

Read-only  

Returns the URL of the document containing the object element. Most commonly, the value is the same as the location.href of the current window. Note the unusual letter case.

 
Example
 
var where = document.getElementById("myObject").BaseHref;
 
Value

URL string.

 
Default

Current document's URL.

borderNN 6 IE 6(Win) DOM 1  

Read/Write  

Controls the thickness of the border in pixels. For cross-browser compatibility use string values.

 
Example
 
document.getElementById("myObject").border = "5";
 
Value

Number as string.

 
Default

0

contains( )NN n/a IE 4 DOM n/a  

contains(elementReference)

  

Returns whether the current element contains the specified element.

 
Parameters
 
  • A fully formed element object reference (e.g., document.getElementById("myDIV")).
 
Returned Value

Boolean value: true | false.

classidNN n/a IE 4 DOM n/a  

Read-only  

Provides the URL of the object's implementation. In Internet Explorer, the URL can point to the client computer's CLSID directory (with a clsid: URL) that stores all the IDs for registered ActiveX controls, such as DirectX or Media Player. IE 4 for Macintosh names this property classID, but the name was repaired to all lowercase in IE 4.5. The W3C DOM omits this property, even though HTML 4 includes the corresponding attribute.

 
Example
 
if (document.getElementById("soundObject").classid ==
    "clsid:83A38BF0-B33A-A4FF-C619A82E891D"){
    // process for the desired sound object
}
 
Value

String (including the clsid: protocol for local ActiveX controls).

 
Default

None.

codeNN 6 IE 4 DOM 1  

Read-only  

Provides the name of the Java applet class file set to the code attribute of the object element (when using an object element in lieu of an applet elementif supported by your browsers).

 
Example
 
if (document.getElementById("clock").code == "Y2Kcounter.class") {
    // process for the found class file
}
 
Value

Case-sensitive applet class filename as a string.

 
Default

None.

codeBaseNN 6 IE 4 DOM 1  

Read-only  

This is the path to the directory holding the class file designated in either the code or classid attribute. The codebase attribute does not name the class file, just the path.

 
Example
 
if (document.getElementById("clock").codeBase == "classes") {
    // process for the found class file directory
}
 
Value

Case-sensitive pathname, usually relative to the directory storing the current HTML document.

 
Default

None.

codeTypeNN 6 IE 4 DOM 1  

Read/Write  

Provides an advisory about the content type of the object referred to by the classid attribute. A browser might use this information to assist in preparing support for a resource requiring a multimedia player or plugin. If the codetype property is set to an empty string, the browser looks next for the type attribute setting (although it is normally associated with content linked by the data attribute URL). If both attributes have no (or empty) values set, the browser gets the content type information from the resource as it downloads.

 
Example
 
document.getElementById("gameTime").codeType = "application/x-crossword";
 
Value

Case-insensitive MIME type. A catalog of registered MIME types is available from ftp://ftp.isi.edu/in-notes/iana/assignments/media-types/.

 
Default

None.

contentDocumentNN 6 IE n/a DOM 2  

Read-only  

Refers to a document node created by the object element, if any.

 
Value

Document node reference or null.

 
Default

null

dataNN 6 IE 4 DOM 1  

Read-only  

URL of a file containing data for the object element (as distinguished from the object itself). Relative URLs are calculated relative to the codebase attribute if one is assigned; otherwise, the URL is relative to the document's URL.

 
Example
 
var objDataURL = document.getElementById("soundEffect").data;
 
Value

A complete or relative URL as a string.

 
Default

None.

dataFldNN n/a IE 4 DOM n/a  

Read/Write  

Used with IE data binding to associate a remote data source column name to an object element attribute determined by properties set in the object. A datasrc attribute must also be set for the element. Setting both the dataFld and dataSrc properties to empty strings breaks the binding between element and data source.

 
Example
 
document.getElementById("myObject").dataFld = "streamURL";
 
Value

Case-sensitive identifier of the data source column.

 
Default

None.

dataSrcNN n/a IE 4 DOM n/a  

Read/Write  

Used with IE data binding to specify the ID of the page's object element that loads the data source object for remote data access (an object element other than the current one). Setting both the dataFld and dataSrc properties to empty strings breaks the binding between element and data source.

 
Example
 
document.getElementById("myObject").dataSrc = "DBSRC3";
 
Value

Case-sensitive identifier of the data source.

 
Default

None.

declareNN 6 IE 6 DOM 1  

Read/Write  

Reflects the declare attribute. As of Version 6 browsers, has no effect on the content.

 
Value

Boolean value: true | false.

 
Default

false

formNN 6 IE 4 DOM 1  

Read-only  

Returns a reference to the form element that contains the current element (if any). This property is appropriate only if the object is acting as a form control. Not available in IE 4.0 for the Macintosh.

 
Value

Object reference or null.

 
Default

None.

getBoundingClientRect( )NN n/a IE 5(Win) DOM n/a  

  

Returns an IE TextRectangle object that describes the rectangular space occupied by the current element (including non-text elements, such as images). The rectangle (which has properties for top, right, bottom, and left coordinates) is as wide as the widest point of the content (e.g, the longest line of a word-wrapped paragraph) and as tall as the sum of all content. To obtain measures of rectangles for individual lines of a text element, see the getClientRects( ) method.

 
Parameters

None.

 
Returned Value

TextRectangle object.

getClientRects( )NN n/a IE 5(Win) DOM n/a  

  

Returns an array of IE TextRectangle objects. Each entry of the array is a TextRectangle object for a single line of a multiline text element. Lines that have different font sizes or line heights will be encased by rectangles that are of different heights. See the TextRectangle object for its properties. To obtain one TextRectangle object for an entire element, use the getBoundingClientRect( ) method.

 
Parameters

None.

 
Returned Value

Array of TextRectangle objects.

height, widthNN 6 IE 4 DOM 1  

Read/Write  

Provide the height and width of the element, in pixels. Changes to these values are immediately reflected in reflowed content on the page.

 
Example
 
document.getElementById("myObject").height = 250;
 
Value

Integer.

 
Default

None.

hspace, vspaceNN 6 IE 4 DOM 1  

Read/Write  

Provide the pixel measure of horizontal and vertical margins surrounding an object element. The hspace property affects the left and right edges of the element equally; the vspace affects the top and bottom edges of the element equally. These margins are not the same as margins set by style sheets, but they have the same visual effect.

 
Example
 
document.getElementById("myObject").hspace = 5;
document.getElementById("myObject").vspace = 8;
 
Value

Integer of pixel count as string.

 
Default

0

isDisabledNN n/a IE 5.5(Win) DOM n/a  

Read-only  

Specifies whether the current element is disabled. Reveals the actual disabled state as either explicitly set for the element or inherited from its ancestor tree.

 
Example
 
if (document.getElementById("elementID").isDisabled) {
		    // process the disabled element
		}
 
Value

Boolean value: true | false.

 
Default

false

langNN 6 IE 4 DOM 1  

Read/Write  

Indicates the written language being used for the element's attribute and property values. Other applications and search engines might use this information to aid selection of spellchecking dictionaries and creating indices.

 
Example
 
document.getElementById("elementID").lang = "de";
 
Value

Case-insensitive language code.

 
Default

Browser default.

languageNN n/a IE 4 DOM n/a  

Read/Write  

Indicates the scripting language for script statements defined in the element.

 
Example
 
document.getElementById("elementID").language = "vbscript";
 
Value

Case-insensitive scripting language name as string: javascript | jscript | vbs | vbscript.

 
Default

jscript

nameNN 6 IE 4 DOM 1  

Read/Write  

This is the identifier associated with the object element. If the object should be one that goes inside a form, the name property is submitted as one-half of the name/value pair when the form is submitted to the server.

 
Example
 
document.getElementById("myObject").name = "company";
 
Value

Case-sensitive string identifier that follows the rules of identifier naming: it may contain no whitespace, cannot begin with a numeral, and should avoid punctuation except for the underscore character.

 
Default

None.

objectNN n/a IE 4 DOM n/a  

Read-only  

Provides a reference to a wrapper around an object to allow access to document object model properties of the object element when the names may be confused with internal property naming of the object. For example, if the code loaded into an object element had a property named hspace, the script reference document.getElementById("reader").object.hspace would retrieve that internal property, rather than the hspace property of the HTML element. The object property wrapper tells the JavaScript interpreter to get the property from the HTML element without diving into the external object's code.

 
Example
 
var objCode = document.getElementById("reader").object.code;
 
Value

Object reference.

 
Default

None.

readyStateNN n/a IE 4 DOM n/a  

Read-only  

Returns the current download status of the object's content. If a script (especially one initiated by a user event) can perform some actions while the document is still loading, but must avoid other actions until the entire page has loaded, this property provides intermediate information about the loading process. You should use its value in condition tests. The value of this property changes during loading as the loading state changes. Each change of the property value fires an onReadyStateChange event (the event does not bubble).

 

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.

 
Example
 
if (document.readyState == "loading") {
		    //statements for alternate handling while loading
		}
 
Value

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).

 
Default

None.

releaseCapture( )NN n/a IE 5(Win) DOM n/a  

  

Turns off mouse event capture mode that had been engaged earlier by the setCapture( ) method. In the IE event model, mouse event capture is designed for temporary use, such as processing mouse events while a custom context menu (implemented as a positioned div element) is activated. IE event capture is also released automatically by several user actions: giving focus to another window, frame, or the browser's Address box; scrolling a window; displaying a system dialog box; or displaying the true context menu.

 
Parameters

None.

 
Returned Value

None.

setCapture( )NN n/a IE 5(Win) DOM n/a  

setCapture([containerFlag])

  

Initiates IE capture mode for all click-related mouse events (onclick, ondblclick, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup), sending all event processing for those events to the current element, regardless of the actual event target. Useful for mouse modality required while handling custom context menus or dragging. While capture is engaged, the event.srcElement property for each event holds a reference to the element that would normally receive the event, but only the capture-mode element's event handlers actually process the events. When your modal effect is no longer neeeded, disengage capture mode with the releaseCapture( ) method. IE event capture is also released automatically by several user actions: giving focus to another window, frame, or the browser's Address box; scrolling a window; displaying a system dialog box; or displaying the true context menu.

 

Starting with IE 5.5, an optional parameter provides more control over event propagation when a user triggers a mouse event atop an element whose parent has the capture mode set. The default behavior (parameter omitted or set to true) causes the parent container to intercept events, as you would expect. But if you set the parameter to false, you direct events to proceed intially to their event targets (descendant elements of the capture-mode element). Such events can then bubble upward as normal; all other mouse events proceed directly to the capture-mode element. For example, if you invoke the setCapture( ) method on an element that contains a form with clickable form controls, you will probably want to use the false parameter so that mouse actions (such as clicking in text boxes) reach their intended targets even while capture mode is on. Otherwise, descendant elements won't respond to mouse activity, and the form controls will act as if they were disabled.

 
Parameters
 
  • Boolean true (default) to let current element (if a container) capture all mouse events, or false to let mouse events reach their intended targets before bubbling.
 
Returned Value

None.

standbyNN 6 IE 5(Mac)/6(Win) DOM 1  

Read-only  

This will eventually assume the duty of the alt attribute for displaying a message during loading. Currently has no effect on the element.

 
Value

String.

 
Default

None.

tabIndexNN 6 IE 4 DOM 1  

Read/Write  

This is a number that indicates the sequence of this element within the tabbing order of all focusable elements in the document. Tabbing order follows a strict set of rules. Elements that have values other than zero assigned to their tabIndex properties are first in line when a user starts tabbing in a page. Focus starts with the element with the lowest tabIndex value and proceeds in order to the highest value, regardless of physical location on the page or in the document. If two elements have the same tabIndex values, the element that comes earlier in the document receives focus first. Next come all elements that either don't support the tabIndex property or have the value set to zero. These elements receive focus in the order in which they appear in the document.

 

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.

 
Example
 
document.getElementById("link3").tabIndex = 6;
 
Value

Integer.

 
Default

0

typeNN 6 IE 4 DOM 1  

Read/Write  

Provides an advisory about the MIME type of the external data to be loaded into the object. The browser looks to the type property value if the codeType property is null.

 
Example
 
if (document.getElementById("myObject").type == "image/jpeg") {
    ...
}
 
Value

Case-insensitive MIME type. A catalog of registered MIME types is available from ftp://ftp.isi.edu/in-notes/iana/assignments/media-types/.

 
Default

None.

useMapNN 6 IE 6 DOM 1  

Read/Write  

Provides the URL of the map element in the same document that contains client-side image map hot areas and links. The value includes the hash mark assigned with the map name in the usemap attribute of the object element.

 
Example
 
document.getElementById("logoViewer").useMap = "#altMap";
 
Value

A string starting with a hash mark and the name of the map element.

 
Default

None.

vspace  

  

See hspace.

width  

  

See height.