[daily study] BOM_사용자와 커뮤니케이션

11055 단어 JavaScriptJavaScript

*본 글은 생활코딩 강의를 듣고 복습을 위해 작성했습니다.


🙋‍♀️html은 form을 통해 사용자와 커뮤니케이션 할 수 있는 기능을 제공한다.


1. alert

<!DOCTYPE html>
<html lang="ko">
<head>
    <title>Document</title>
</head>

<body>
   <script>
     	 alert('hello world');
 	</script>
</body>
</html>

👉 경고창이나 알림창의 용도로 쓰인다. 확인버튼 밖에 사용할 수 없다. 개발자의 의도는 아니였겠지만 강의를 가만히 들어보면 수업에 꽤나 유용하게 쓰인다.




2. confirm

<!DOCTYPE html>
<html lang="ko">
<head>
    <title>Document</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>

👉 alert과는 다르게 확인과 취소 버튼이 있고 어떤 버튼을 선택하느냐에 따라 true나 false의 결과를 불러온다.

3. prompt

<!DOCTYPE html>
<html lang="ko">
<head>
    <title>Document</title>
</head>
<body>
  <input type="button" value="prompt" onclick="func_prompt()" />
   <script>
     	 function func_prompt(){
             if(prompt('id') === 'jealousy'){
                alert('welcome');
            }else{
                alert('fail');
            }
         }
 	</script>
</body>
</html>

👉 alert나 confirm과는 다르게 입력할 수 있는 창있다. 입력 결과에 따라서 ture나 false의 결과를 불러온다.




*위 글의 이론적인 부분은 생활코딩의 사용자와 커뮤니케이션하기에서 가져왔음을 밝힙니다.
출처 : https://opentutorials.org/course/1375/6632

좋은 웹페이지 즐겨찾기