compareDocumentPosition
compareDocumentPosition
This page has been flagged with the following issues:
High-level issues:
W3C Recommendation
Summary
Compares the position of two nodes in a document.
Method of dom/Node
Syntax
var positionBitmask = node.compareDocumentPosition(otherNode);
Parameters
otherNode
Data-type: DOM Node
The node to be compared to the reference node, which is the node executing the method.
Return Value
Returns an object of type Number.
Describes how the position of the node specified by the otherNode parameter relates to the position of the reference node. The return value contains one or more of the following flag values:
| Node constant name | Return value (Integer) | Return value (Hexadecimal) | Description |
|---|---|---|---|
| DOCUMENT_POSITION_DISCONNECTED | 1 | 0x01 | The nodes are disconnected. |
| DOCUMENT_POSITION_PRECEDING | 2 | 0x02 | The position of the node specified by the otherNode parameter precedes the position of the reference node. |
| DOCUMENT_POSITION_FOLLOWING | 4 | 0x04 | The position of the node specified by the otherNode parameter follows the position of the reference node. |
| DOCUMENT_POSITION_CONTAINS | 8 | 0x08 | The reference node contains the node specified by the otherNode parameter. |
| DOCUMENT_POSITION_CONTAINED_BY | 16 | 0x10 | The node specified by the otherNode parameter contains the reference node. |
| DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | 32 | 0x20 | The node positions depend on the DOM implementation and cannot be compared. |
Needs Examples: This section should include examples.
Notes
For information about the factors that affect the position of nodes within the DOM, see the related specifications.
Related specifications
| Specification | Status | Related Changes |
|---|---|---|
| DOM Level 3 Core | Recommendation | Section 1.2 |
Compatibility
Desktop
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic Support | ? | ? | 9 | ? |
? |
Mobile
| Feature | Android | BlackBerry | Chrome for mobile | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Opera Mini | Safari Mobile |
|---|---|---|---|---|---|---|---|---|
| Basic support | ? | ? | ? | ? | ? | ? | ? | ? |
See also
Related pages (MSDN)
aappletattributeaudiobuttondivdocumentdocumentTypeProcessingInstructionframeiframeimginput type=buttoninput type=checkboxinput type=fileinput type=hiddeninput type=imageinput type=passwordinput type=radioinput type=resetinput type=submitinput type=textlabellegendmarqueemediaobjectoptGroupoptionselectsourcespantabletextAreaTextNodevideo
This article contains content originally from external sources.
Portions of this content come from the Microsoft Developer Network: [Windows Internet Explorer API reference Article]
This tool helps to make and review comments inline.
How to Use
insert instructions, with images, here