← Back to Target domain

Target.createTarget

Creates a new page.

Domain: Target stable

Parameters

NameTypeDescription
urlstringThe initial URL the page will be navigated to. An empty string indicates about:blank.
left (optional)integerFrame left origin in DIP (requires newWindow to be true or headless shell).
top (optional)integerFrame top origin in DIP (requires newWindow to be true or headless shell).
width (optional)integerFrame width in DIP (requires newWindow to be true or headless shell).
height (optional)integerFrame height in DIP (requires newWindow to be true or headless shell).
windowState (optional)WindowStateFrame window state (requires newWindow to be true or headless shell). Default is normal.
browserContextId (optional)Browser.BrowserContextIDThe browser context to create the page in.
enableBeginFrameControl (optional)booleanWhether BeginFrames for this target will be controlled via DevTools (headless shell only, not supported on MacOS yet, false by default).
newWindow (optional)booleanWhether to create a new Window or Tab (false by default, not supported by headless shell).
background (optional)booleanWhether to create the target in background or foreground (false by default, not supported by headless shell).
forTab (optional)booleanWhether to create the target of type "tab".
hidden (optional)booleanWhether to create a hidden target. The hidden target is observable via protocol, but not present in the tab UI strip. Cannot be created with `forTab: true`, `newWindow: true` or `background: false`. The life-time of the tab is limited to the life-time of the session.
focus (optional)booleanIf specified, the option is used to determine if the new target should be focused or not. By default, the focus behavior depends on the value of the background field. For example, background=false and focus=false will result in the target tab being opened but the browser window remain unchanged (if it was in the background, it will remain in the background) and background=false with focus=undefined will result in the window being focused. Using background: true and focus: true is not supported and will result in an error.

Returns

NameTypeDescription
targetIdTargetIDThe id of the page opened.

Example Request

{
  "id": 1,
  "method": "Target.createTarget",
  "params": {
    "url": "https://example.com"
  }
}

Example Response

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

Usage in Node.js

const result = await send('Target.createTarget', {"url": "https://example.com"});
console.log(result);
// {"targetId": "TARGET_NEW_001"}