# Interaction: alert, prompt, confirm

## alert

顯示一段訊息，停止執行 Script，期間使用者無法做任何操作直到按 ok。

```javascript
alert(message);

alert("Hello");
```

## prompt

裡面可以放 2 個參數，顯示要使用者輸入資訊，有 ok、cancel 可以選，返回使用者輸入資訊。

```javascript
result = prompt(title, [default]);

let age = prompt('How old are you?', 100);
alert(`You are ${age} years old!`); // You are 100 years old!
```

## confirm

顯示要問的問題，有 ok、cancel 可以選，返回布林值。

```javascript
result = confirm(question);

let isBoss = confirm("Are you the boss?");
alert( isBoss ); // true if OK is pressed
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mistborn.gitbook.io/til-coding/javascript/interaction-alert-prompt-confirm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
