Node.compareDocumentPosition(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Returns a number that reflects where two nodes are located, compared to each other. Returns one of the following numbers:

  • 1. The two nodes do not belong to the same document.

  • 2. The specified node comes before the current node.

  • 4. The specified node comes after the current node.

  • 8. The specified node contains the current node.

  • 16. The current node contains the specified node.

  • 32. The specified and current nodes do not have a common container node or the two nodes are different attributes of the same node.

Note:

The return value can be a combination of the above values. For example, a return value of 20 means the specified node is contained by the current node, a value of 16, and the specified node follows the current node, a value of 4.

Important:

This method is not supported on Internet Explorer.

Returns

number

Supported Script Types

Client and server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

None

Module

N/xml Module

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

options.other

xml.Node

required

The node to compare with the current node.

Errors

Error Code

Message

Thrown If

SSS_XML_DOM_EXCEPTION

Invalid argument type, expected xml.Node or subclass: other

The options.other is of type xml.Node.

Syntax
Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/xml Module Script Samples.

          //Add additional code 
...
var posCode = elem[0].compareDocumentPosition({
    other : parentNode[0]
});
... 
//Add additional code 

        

Related Topics

xml.Node
N/xml Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices