browser_set_popup_policy
Browser Set Popup Policy
Configure how popup windows are handled when JavaScript calls window.open() or links have target='_blank'. Options: 'allow' opens new window, 'block' prevents popup entirely, 'new_tab' opens in foreground tab, 'background' opens in background tab. Default behavior may vary by browser.
Usage Example
123456789101112
import asyncio
from owl_browser import OwlBrowser, RemoteConfig
# Async usage
async with OwlBrowser(config) as browser:
context = await browser.create_context()
context_id = context["context_id"]
await browser.set_popup_policy(
context_id=context_id,
policy="allow"
)
Parameters
Required
context_idstringrequiredThe unique identifier of the browser context (e.g., 'ctx_000001')
policyenumallowblocknew_tabbackgroundHow to handle popup windows opened by window.open() or target='_blank' links: 'allow' opens in new window, 'block' prevents popup, 'new_tab' opens in foreground tab, 'background' opens in background tab
Response
Returns a JSON object with the operation result.
{
"success": true,
"result": <value>
}