| Availability: |
| ||||||
| Inherits from: | Element object | ||||||
| JavaScript syntax: | IE | myDIV = myDocument.all.anElementID | |||||
| IE | myDIV = myDocument.all.tags("DIV")[anIndex] | ||||||
| IE | myDIV = myDocument.all[aName] | ||||||
| - | myDIV = myDocument.getElementById(anElementID) | ||||||
| - | myDIV = myDocument.getElementsByName(aName)[anIndex] | ||||||
| - | myDIV = myDocument.getElementsByTagName("DIV")[anIndex] | ||||||
| HTML syntax: | <DIV> ... </DIV> | ||||||
| Argument list: | anIndex | A reference to an element in a collection | |||||
| aName | An associative array reference | ||||||
| anElementID | The ID value of an Element object | ||||||
| Object properties: | align, dataFld, dataFormatAs, dataSrc | ||||||
| Event handlers: | onAfterUpdate, onBeforeUpdate, onBlur, onChange, onClick, onDblClick, onDragStart, onFocus, onHelp, onKeyDown, onKeyPress, onKeyUp, onMouseDown, onMouseMove, onMouseOut, onMouseOver, onMouseUp, onResize, onRowEnter, onRowExit, onScroll, onSelectStart | ||||||
A DIV object is a means of building a block structured organization of a document that is custom-designed. It is yet another means of building a hierarchical model if none of the existing models fits the structure you need. It is also a way of marking out blocks of a document to be treated as a styled area or perhaps a means of dynamically replacing or modifying document content in an easily controlled manner.
The <DIV> tag is a block-level tag. That means that it forces a line break before and after itself.
The example shows how to exchange the style values between two <DIV> blocks.
In Netscape 4, a <DIV> object whose CSS style defines its positioning as absolute, is then enumerated in the layers collection at an appropriate position in the document/layer hierarchy. This is confusing because a <DIV> is not a <LAYER>. Refer to the discussion about Layer objects in a separate topic for further details.
<HTML>
<HEAD>
</HEAD>
<BODY>
<DIV ID="ONE" STYLE="background-color:RED">
The DIV block ONE
</DIV>
<DIV ID="TWO" STYLE="background-color:BLUE">
The DIV block TWO
</DIV>
<FORM>
<INPUT TYPE="button" VALUE="CLICK ME" onClick="clickMe()">
</FORM>
<SCRIPT>
function clickMe()
{
myStyle1 = document.all.ONE.style.cssText;
myStyle2 = document.all.TWO.style.cssText;
document.all.ONE.style.cssText = myStyle2;
document.all.TWO.style.cssText = myStyle1;
}
</SCRIPT>
</BODY>
</HTML>| Property | JavaScript | JScript | N | IE | Opera | NES | ECMA | DOM | CSS | HTML | Notes |
|---|---|---|---|---|---|---|---|---|---|---|---|
| align | 1.5 ![]() | 3.0 ![]() | 6.0 ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | 1 ![]() | ![]() | ![]() | - |
| dataFld | 1.5 ![]() | 3.0 ![]() | 6.0 ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | 1 ![]() | ![]() | ![]() | ![]() |
| dataFormatAs | 1.5 ![]() | 3.0 ![]() | 6.0 ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | 1 ![]() | ![]() | ![]() | ![]() |
| dataSrc | 1.5 ![]() | 3.0 ![]() | 6.0 ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | 1 ![]() | ![]() | ![]() | ![]() |
| Event name | JavaScript | JScript | N | IE | Opera | NES | ECMA | DOM | CSS | HTML | Notes |
|---|---|---|---|---|---|---|---|---|---|---|---|
| onAfterUpdate | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | - |
| onBeforeUpdate | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | - |
| onBlur | 1.5 ![]() | 3.0 ![]() | 6.0 ![]() | 4.0 ![]() |
| ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| onChange | 1.5 ![]() | 3.0 ![]() | 6.0 ![]() | 4.0 ![]() |
| ![]() | ![]() | ![]() | ![]() | ![]() | - |
| onClick | 1.5 ![]() | 3.0 ![]() | 6.0 ![]() | 4.0 ![]() |
| ![]() | ![]() | ![]() | ![]() | 4.0 ![]() | ![]() |
| onDblClick | 1.5 ![]() | 3.0 ![]() | 6.0 ![]() | 4.0 ![]() |
| ![]() | ![]() | ![]() | ![]() | 4.0 ![]() | ![]() |
| onDragStart | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | - |
| onFocus | 1.5 ![]() | 3.0 ![]() | 6.0 ![]() | 4.0 ![]() |
| ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| onHelp | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| onKeyDown | 1.5 ![]() | 3.0 ![]() | 6.0 ![]() | 4.0 ![]() |
| ![]() | ![]() | ![]() | ![]() | 4.0 ![]() | ![]() |
| onKeyPress | 1.5 ![]() | 3.0 ![]() | 6.0 ![]() | 4.0 ![]() |
| ![]() | ![]() | ![]() | ![]() | 4.0 ![]() | ![]() |
| onKeyUp | 1.5 ![]() | 3.0 ![]() | 6.0 ![]() | 4.0 ![]() |
| ![]() | ![]() | ![]() | ![]() | 4.0 ![]() | ![]() |
| onMouseDown | 1.5 ![]() | 3.0 ![]() | 6.0 ![]() | 4.0 ![]() |
| ![]() | ![]() | ![]() | ![]() | 4.0 ![]() | ![]() |
| onMouseMove | 1.5 ![]() | 3.0 ![]() | 6.0 ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | 4.0 ![]() | ![]() |
| onMouseOut | 1.5 ![]() | 3.0 ![]() | 6.0 ![]() | 4.0 ![]() |
| ![]() | ![]() | ![]() | ![]() | 4.0 ![]() | ![]() |
| onMouseOver | 1.5 ![]() | 3.0 ![]() | 6.0 ![]() | 4.0 ![]() |
| ![]() | ![]() | ![]() | ![]() | 4.0 ![]() | ![]() |
| onMouseUp | 1.5 ![]() | 3.0 ![]() | 6.0 ![]() | 4.0 ![]() |
| ![]() | ![]() | ![]() | ![]() | 4.0 ![]() | ![]() |
| onResize | 1.5 ![]() | 3.0 ![]() | 6.0 ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| onRowEnter | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | - |
| onRowExit | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | - |
| onScroll | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | - |
| onSelectStart | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | - |
| Prev | Home | Next |
| disableExternalCapture() | Up | DIV.align |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. | ||