> For the complete documentation index, see [llms.txt](https://docs.zerowork.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zerowork.io/using-zerowork/using-building-blocks/browser-alert.md).

# Browser Alert

<figure><img src="https://3220183989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fg9LcR8XM7TGOzOCDGsCS%2Fuploads%2FssfZlBtOJxYXNOp9kuyd%2Fbrowser_alert_block.png?alt=media&amp;token=9e33f289-bb73-435e-bc0b-719b3d518cb1" alt="" width="358"><figcaption></figcaption></figure>

The **Browser Alert** block tells your TaskBot to **accept** the next native browser dialog (an alert, confirm, prompt, or page-exit pop-up) instead of dismissing it.

{% hint style="warning" %}
This block only handles **native** browser dialogs: the ones the browser draws *outside* the page, that freeze it until answered and can't be styled by the site. It does **not** handle **in-page modals** built into a website, like cookie banners, newsletter popups, or a site's own custom "Are you sure?" box. Those are ordinary page elements; close or answer them with [Click Web Element](https://docs.zerowork.io/using-zerowork/using-building-blocks/click-web-element) and the usual selectors.\
\
Quick test: if a selector picker can grab the popup's buttons, it's an in-page modal (not this block); if it can't, it's a native dialog (this block).
{% endhint %}

## The 4 Browser Dialog Types

Browsers show four kinds of native dialogs. Your TaskBot dismisses each of them by default; a Browser Alert block accepts the next one instead. What **accept** and **dismiss** actually do depends on the type of browser dialog being displayed.

| Browser Dialog Type | What It Looks Like                                                         | Without This Block | With This Block                                             |
| ------------------- | -------------------------------------------------------------------------- | ------------------ | ----------------------------------------------------------- |
| **Alert**           | A message with a single **OK** button                                      | Clicks **OK**      | Clicks **OK** (the same thing your TaskBot does by default) |
| **Confirm**         | A yes/no box with **OK** and **Cancel**                                    | Clicks **Cancel**  | Clicks **OK**                                               |
| **Prompt**          | A box with a **text field** plus OK and Cancel                             | Clicks **Cancel**  | Submits your **Prompt response**                            |
| **Page exit**       | The **Leave / Stay** warning shown before navigating away (`beforeunload`) | Stays on the page  | Leaves the page                                             |

{% hint style="info" %}
For an **Alert** this block does nothing useful; there's only OK to click. It matters for the other three, where the default (Cancel / Stay) is often not what you want.
{% endhint %}

## How To Use It

<figure><img src="https://3220183989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fg9LcR8XM7TGOzOCDGsCS%2Fuploads%2FyNPx4qwZPgQNZGvYNHv8%2Fbrowser_alert_settings.png?alt=media&amp;token=8b4ee211-da03-4efd-8ee4-5f293323c551" alt=""><figcaption></figcaption></figure>

Place the Browser Alert block **immediately after the action that triggers the dialog**: the click, navigation, or other step that makes it pop up. ZeroWork arms the accept *before* running that action, so the dialog is handled the moment it appears.

### Prompt Response

For a **prompt** dialog, enter the text to submit as its answer. This field is optional and is ignored for alert, confirm, and page-exit dialogs because those have no text field.

#### Block-level Delays

**Min sec** and **Max sec** represent a pause after this block's action completes, before the next block runs. The wait is randomized between the two values, and setting both to the same number makes it fixed. This block defaults to **0**, meaning no pause.

{% hint style="info" %}
See the [Delay](https://docs.zerowork.io/using-zerowork/using-building-blocks/delay) block for how these two fields behave, including decimals, references, and what happens when a field is left empty. See [Delay Times between the Building Blocks](https://docs.zerowork.io/using-zerowork/using-building-blocks/building-block-options/delay-times-between-the-building-blocks) for how block-level delays fit into a TaskBot's run.
{% endhint %}

## Things To Know

* **Dismiss is the default; this block flips one browser dialog to accept.** Without a Browser Alert block, every native dialog is dismissed automatically and noted in your [Run Reports](/using-zerowork/using-run-reports.md). This block changes the **next** dialog to accept instead.
* **One block handles one browser dialog.** To accept several dialogs in a run, place one Browser Alert block after each action that triggers one. Consecutive Browser Alert blocks chain; each arms the next dialog.
* **If no dialog appears, nothing happens.** The block logs a warning and the run continues, so a Browser Alert block placed "just in case" is harmless.

## Block Behavior

**When a dialog appears** the block accepts it (submitting your Prompt response for a prompt dialog) and logs that it accepted the dialog.

**When no dialog appears** the block takes no action, logs a warning that no dialog appeared, and the run continues.

**Without this block (the default)** any dialog that appears is dismissed (the equivalent of Cancel) and logs as a dismissal, with a note to use the Browser Alert block if you meant to accept it.
