← Back to DOM domain

DOM.scrollIntoViewIfNeeded

Scrolls the specified rect of the given node into view if not already visible. Note: exactly one between nodeId, backendNodeId and objectId should be passed to identify the node.

Domain: DOM stable

Parameters

NameTypeDescription
nodeId (optional)NodeIdIdentifier of the node.
backendNodeId (optional)BackendNodeIdIdentifier of the backend node.
objectId (optional)Runtime.RemoteObjectIdJavaScript object id of the node wrapper.
rect (optional)RectThe rect to be scrolled into view, relative to the node's border box, in CSS pixels. When omitted, center of the node will be used, similar to Element.scrollIntoView.

Example Request

{
  "id": 1,
  "method": "DOM.scrollIntoViewIfNeeded"
}

Example Response

{
  "id": 1,
  "result": {}
}

Usage in Node.js

const result = await send('DOM.scrollIntoViewIfNeeded');
console.log(result);