---
title: "Dialogs"
description: "JavaScript dialogs over CDP."
---

> Documentation Index
> Fetch the complete documentation index at: https://help.tooluse.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Dialogs

<p>Use the session’s CDP connection to observe <code>Page.javascriptDialogOpening</code> and respond with <code>Page.handleJavaScriptDialog</code>. Register the handler before navigating or clicking the action that opens a dialog.</p>
<pre><code class="language-javascript">// client is an already connected, page-scoped CDP session.
await client.send("Page.enable");
client.on("Page.javascriptDialogOpening", async () =&gt; {
  await client.send("Page.handleJavaScriptDialog", {accept: false});
});
</code></pre>
<p>Choose acceptance or prompt text according to the intended user action. Browser permission prompts, website sign-in and human checks are different from JavaScript alert, confirm and prompt dialogs.</p>
<p>See <a href="/browsers/getting-started/create-browser-session">Create a browser session</a> and the <a href="/browsers/api">Browsers API</a> for authentication, request fields, and limits.</p>

Source: https://help.tooluse.net/browsers/techniques/dialogues/index.mdx
