The browsingContext.activate command of the browsingContext module brings a top-level context to the foreground and gives it focus.
Syntax
{
"method": "browsingContext.activate",
"params": {
"context": "93ee5bd6-d256-4608-a002-9a8995cc0e5f"
}
}
Parameters
The params field contains:
context- : A string that contains the ID of the top-level context to bring to the foreground and give focus.
Context IDs are returned by commands such as
browsingContext.getTree.
- : A string that contains the ID of the top-level context to bring to the foreground and give focus.
Context IDs are returned by commands such as
Return value
The result field in the response is an empty object ({}).
Errors
invalid argument- : A required parameter is missing or has an invalid type.
This error is also returned when the context specified by
contextis not a top-level context.
- : A required parameter is missing or has an invalid type.
This error is also returned when the context specified by
no such frame- : No context with the given context ID is found.
unsupported operation- : The browser cannot bring the context to the foreground.
Examples
Activating a background tab
The following example shows how to activate a background tab.
With a WebDriver BiDi connection and an active session, suppose you create a tab in the background using browsingContext.create with background: true, which returns the context ID of the tab. Send the following message to activate it:
{
"id": 1,
"method": "browsingContext.activate",
"params": {
"context": "5e5e96e8-5247-4f22-9b35-a4a2d841cbaa"
}
}
The browser brings the tab to the foreground and responds as follows:
{
"id": 1,
"type": "success",
"result": {}
}
Specifications
Browser compatibility
See also
browsingContext.closecommandbrowsingContext.createcommandbrowsingContext.getTreecommand
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
