> For the complete documentation index, see [llms.txt](https://phg0644.gitbook.io/javascript-and-browser/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://phg0644.gitbook.io/javascript-and-browser/bom/undefined.md).

# 사용자와 커뮤니케이션 하기

## alert(경고창)

* 사용자에게 정보를 제공하거나 경고를 하는데 사용
* 자바스크립트를 실행중에는 다음 코드를 진행하지 않

```markup
<!DOCTYPE html>
<html lang="ko">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title></title>
</head>
<body>
  <!--  클릭시 경고창  -->
  <input type="button" value="alert" onclick="alert('hello world');">
</body>
</html>
```

{% embed url="<https://codepen.io/hyeongkyupark/pen/JjWBjdO>" %}

## confirm

* 확인을 누르면 true, 취소를 누르면 false를 리턴

```markup
<!DOCTYPE html>
<html lang="ko">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title></title>
</head>
<body>
  <input type="button" value="confirm" onClick="func_confirm()" />
  
  <script>
    function func_confirm() {
      if(confirm('ok??')) {
        alert('ok');
      } else {
        alert('cancel');
      }
    }
  </script>
</body>
</html>
```

{% embed url="<https://codepen.io/hyeongkyupark/pen/LYWBYNd>" %}

## prompt

* 사용자의 입력을 받아서 자바스크립트에서 사용할 수 있게 해주는 함수
* 사용자 입력값 반환

```markup
<!DOCTYPE html>
<html lang="ko">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title></title>
</head>
<body>
  <input type="button" value="prompt" onclick="func_prompt()" />
  
  <script>
    // 사용자가 입력한 값을 버튼에 삽
    function func_prompt() {
      var answer = prompt('button value : ');
      
      document.querySelector('input').value = answer;
    }
  </script>
</body>
</html>
```

{% embed url="<https://codepen.io/hyeongkyupark/pen/vYxaYyQ>" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://phg0644.gitbook.io/javascript-and-browser/bom/undefined.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
